home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
UTILITIE
/
CPU_MEMO
/
1648.ZIP
/
TESS-D.ARC
/
TESSDOC.LST
next >
Wrap
File List
|
1988-10-02
|
154KB
|
4,756 lines
TesSeRact(TM)
A Library of Routines for Developing Ram-Resident Programs
and
A Proposed Standard for Ram-Resident Program Communication
Documentation Version 1.00
July 1, 1988
Copyright (c) 1988, TesSeRact Development Team
All Rights Reserved
_______
____|__ | (TM)
--| | |-------------------
| ____|__ | Association of
| | |_| Shareware
|__| o | Professionals
-----| | |---------------------
|___|___| MEMBER
Table of Contents
Preface........................................................iv
If you've never written a TSR.............................iv
A note about DOS Versions..................................v
How to Use This Manual.........................................vi
Acknowledgements..............................................vii
The TesSeRact Development Team...........................vii
Chapter 1. Legal Stuff.........................................1
Copyright Notice and Software License......................1
Warranty...................................................2
Registered User License....................................2
Source Code License........................................3
Required and Suggested Notices.............................3
Chapter 2. Shareware Terms.....................................5
Technical Support..........................................6
-i-
Association of Shareware Professionals.....................7
Standards.............................................7
Order Form.................................................9
Chapter 3. History of TesSeRact................................10
Chapter 4. TesSeRact Data Structures and Variables............11
A Quick Note about Graphics Modes.........................11
TesSeRact Data Structures.................................12
TsrIntTable..........................................12
ExtraHot.............................................12
TsrData..............................................13
TsrParms.............................................15
Other PUBLIC, Global Variables............................16
Equates and Definitions...................................17
Chapter 5. TesSeRact External Functions.......................18
TsrMain...................................................19
TsrBackCheck..............................................20
TsrBackProc...............................................21
TsrTimerProc..............................................22
TsrUserProc...............................................23
TsrCleanUp................................................24
Chapter 6. TesSeRact Library Routines.........................25
TsSetStack................................................26
TsCheckResident...........................................28
TsDoInit..................................................30
TsVerify2F................................................32
TessBeep..................................................33
Chapter 7. TesSeRact Multiplex Functions......................34
Initialization and Information Routines...................34
Check Install (Function 00h).........................35
Return User Parameter Pointer (Function 01h).........36
Check Hotkey (Function 02h)..........................37
Replace Default Interrupt 24h Handler (Function 03h).38
Return TesSeRact Data Pointer (Function 04h).........39
Set Multiple Hot Keys (Function 05h).................40
TSR Manipulation and Status Routines......................41
Enable TSR (Function 10h)............................42
Disable TSR (Function 11h)...........................43
Release TSR [unload] (Function 12h)..................44
Restart TSR (Function 13h)...........................45
Get TSR Status Word (Function 14h)...................46
Set TSR Status Word (Function 15h)...................47
Get Indos State at Popup (Function 16h)..............48
TSR Utility Routines......................................49
Call User Procedure (Function 20h)...................50
Stuff Keyboard (Function 21h)........................51
Chapter 8. Writing a TesSeRact TSR -- A Tutorial..............53
Chapter 9. Language Specifics.................................55
Turbo C...................................................55
Microsoft C...............................................56
-ii-
Turbo Pascal..............................................57
Assembler.................................................58
Chapter 10. Communicating with the TesSeRact..................59
Chapter 11. Writing TesSeRact-Compatible Programs.............65
Appendix A. Quick Reference to TesSeRact Functions............69
Appendix B. Keyboard Scan Codes...............................70
Appendix C. Reporting Bugs....................................71
Glossary.......................................................72
Index..........................................................74
-iii-
Preface
TesSeRact consists of two major parts: a library of routines (.LIB, .OBJ,
.TPU files) that allow a developer to write Ram-Resident, or TSR (Terminate
But Stay Resident) programs; and a set of functions that attempts to
standardize communication with and between TSR-type programs.
The TesSeRact libraries and modules allow developers to write Ram-Resident
programs with little or no knowledge of the arcane art of disassembling
DOS, something that has been sorely lacking for some time. Among the
features provided are easy use of hotkeys, simple Ram-Resident routines,
co-resident functions, and cross-routine communication facilities. These
libraries and modules provided with the TesSeRact package have been tested
with Turbo C version 1.5, Turbo Pascal 4.0, Microsoft C version 5.0 and
5.1, Microsoft's Macro Assembler 5.0 and 5.1, and OPTASM version 1.0. Also
note that these routines work on the Heath/Zenith Z-100 computer (using the
ZPC Hardware Modifications), with the exception of the keyboard stuff
routines. This is mentioned because this computer is used extensively by
government offices, and is generally considered only marginally compatible.
The TesSeRact Standard for Ram-Resident Program Communication is a group of
functions latched onto DOS' own Interrupt 2Fh (Multiplex). DOS uses this
interrupt to communicate with its own TSRs (PRINT.COM, ASSIGN.COM,
SHARE.COM), and the TesSeRact Development Team felt it was appropriate to
service TSR programs using the same interface. These functions are all
accessed by generating an Interrupt 2Fh, with AX=5453 (hex). Programs may
call these multiplex functions directly or may use the functions provided
in the TESS.LIB or TESS-TP.TPU modules (the assembler version of TesSeRact
does not include callable functions for the Multiplex operations).
If you've never written a TSR
Writing TSR or Ram-Resident Programs is not for the beginner, nor is it for
the faint of heart. Without a product such as TesSeRact, a programmer can
expect to spend a minimum of six months learning how to deal with such
things as a non-reentrant operating system, hardware specifics, BIOS bugs,
and more. And all this has nothing to do with writing the actual
application -- this work will be necessary if a resident program attempts
to do any DOS or BIOS calls from within the resident program.
In developing TesSeRact, and in the writing of this manual, the TesSeRact
Development Team has made certain assumptions concerning the level of
developer experience. We have assumed that developers using this product
have some knowledge of the problems associated with developing resident
programs. Note that it is not necessary to have this background; without
it, however, certain statements will be difficult to comprehend.
-iv-
Writing resident programs, in general, requires a basic understanding of
both documented and undocumented DOS functions. This documentation does
not attempt to detail the undocumented functions; other material provided
by the TesSeRact Development Team may, at some future point, include such
information.
The undocumented functions used by the TesSeRact Library routines have been
documented, in some form, by Microsoft in various publications; the MS-DOS
Encyclopedia, in particular, has about the most complete discussion on
resident programs available. It is not 100% complete, and omits some facts
and observations discovered by some developers, but it's the best.
There are a couple of other books about memory resident programming and a
number of magazines have published articles on the subject. If learning
how to write TSRs is the goal, some of these are good; others are so poor
as to be a waste of money. The TesSeRact Development Team will neither
endorse nor oppose any of these books or articles. Individual team members
will have their own opinions and may feel it appropriate to voice them.
The best way to learn about TSRs, in general, is to study working code.
Books and articles are nice, but generally omit information because of
space limitations or the complexity of the subject. By combining the code
for the demonstration programs, along with the source code for the
TesSeRact Library itself, a developer may learn more than he/she ever
wanted to know about resident programming, and DOS itself.
A note about DOS Versions
TesSeRact has been tested on a wide variety of DOS versions, ranging in
number from 2.0 to 3.3. It is important to note that Microsoft changed
their OEM licensing agreements between DOS versions 2.x and 3.x. OEM
versions of DOS 3.x must maintain certain data areas and undocumented
functions in order to provide compatibility with the networking features of
the operating system. For this reason, resident programs will be much more
reliable when operating under DOS 3.x.
The code needed to support DOS 2.x in the TesSeRact Library amounts to less
than 50 bytes; this deals with known bugs and deficiencies. For this
reason, support for DOS 2.x was left in; however, some OEMs may have
changed some things vital to the correct functioning of a TesSeRact TSR.
If this situation comes up, please contact the TesSeRact Development Team.
-v-
How to Use This Manual
The primary thing to consider is that NOTHING about TesSeRact is intended
to be 'undocumented.' All PUBLIC data areas and procedures should be
described in this documentation. Please comment on all inconsistencies and
unclear documentation contained herein.
Throughout this document, a 'non-zero' return from a function means ANY
value other than zero which is not specifically noted. A specific value
may not be valid in many cases, especially on return from the Multiplex
Functions -- the value returned would be dependent on what other Interrupt
2Fh handlers are installed on the system.
This manual begins with detailed information about the various TesSeRact
Data areas, all internal and external TesSeRact functions, and a
description of each TesSeRact Multiplex Function. This is followed by a
short tutorial, designed to be language-independent, on how to write a
TesSeRact TSR. The next chapter describes various specific information for
using TesSeRact with some popular language products. Note that this
chapter will be expanded as more information is gathered about more
compilers/assemblers.
Next, there is a chapter that may be reproduced (with appropriate copyright
notices) in user documentation. It describes, in a narrative form, how to
use the TesSeRact Multiplex Functions from a user program to find out
information about the TSR.
The next chapter is of interest to developers of TSRs who do not intend to
use the TesSeRact Library itself. This chapter explains how to write a
TesSeRact-compatible TSR and what Multiplex functions need to be supported
for minimum compatibility.
Please contact the TesSeRact Development Team if you find any
inconsistencies or errors in this documentation.
-vi-
Acknowledgements
Grateful appreciation is expressed to CompuServe Information Service,
CompuServe's IBM Software Forums and their Sysops, and Computer Language
Magazine for providing us with the means to accomplish the development of
TesSeRact. Without their gracious assistance, TesSeRact could never have
come into existence.
It is also necessary to thank the beta testers and documentation reviewers
(too numerous to mention here) who spent many hours helping produce
TesSeRact.
And let's not forget Anne Marie, who suffered through the long evenings and
nights spent getting this product ready.
The TesSeRact Development Team:
Chip Rabinowitz
Jim Kyle
TesSeRact is based in part on work done by the Ringmaster Development Team,
in efforts to develop a public domain TSR standard.
The Original Ringmaster Development Team:
Team Leader: Chip Rabinowitz
Developers: Lane Ferris
Kim Kokkonen
Jim Kyle
Neil J. Rubenking
Barry Simon
Rick Wilson
Contributors: Thomas Brandenborg
Chris Dunford
Mark Horvatich
John Hensley
David Moskowitz
Advisors: Robert Bierman
David Intersimone
Rick Kraus
Gary Saxer
-vii-
TesSeRact(TM) Documentation (Ver. 1.00) Page 1
Chapter 1. Legal Stuff
Before beginning this description of TesSeRact, there are a number of legal
considerations to dispense with.
Copyright Notice and Software License
This document; other accompanying written and disk-based notes and
specifications; and all referenced and related program files, demonstration
code and object modules accompanying this document are copyrighted by the
TesSeRact Development Team. The copyright owner hereby licenses you to:
use the software; make as many copies of the software and documentation as
you wish; give exact copies of the original to anyone; and distribute the
software and documentation in its unmodified form via electronic means.
There is no charge for any of the above.
You are specifically prohibited from charging or requesting donations for
any such copies, however made. Exceptions may be granted to organizations
which charge a small fee for materials, handling, postage and general
overhead. NO ORGANIZATION IS AUTHORIZED TO CHARGE ANY AMOUNT FOR
DISTRIBUTION OF THE SOFTWARE OR DOCUMENTATION UNDER ANY OTHER CONDITIONS.
Organizations which charge a fee for distribution of any and all TesSeRact
materials, except as noted above or with the express, written consent of
the TesSeRact Development Team, will be considered in violation of this
copyright and will be prosecuted to the full extent of the law.
In addition, you are specifically prohibited from making any modifications
to the TesSeRact Library Routines and/or documentation unless you have a
license for the use of the code. Under no circumstances is the copyright
notice embedded in the TesSeRact code to be modified or removed.
This is not free software. This license allows you to use this software
without charge for a period of 30 days. In order to include this software
as part of any product, either commercial, shareware, freeware, or public
domain, registration is required. TesSeRact may not be included in any
product for any use without registration. Any such use of the TesSeRact
product is in violation of federal copyright laws and will be prosecuted.
No copy of the software may be distributed or given away without this
accompanying documentation; this notice must not be removed.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 2 TesSeRact(TM) Documentation (Ver. 1.00)
Warranty
There is no warranty of any kind associated with this software, and the
copyright owner is not liable for damages of any kind. By using this
software, you agree to this. Every effort has been made by the TesSeRact
Development Team to make this product bug-free. However, the nature of
software development is that it is impossible to guarantee bug-free
software.
In the event a verifiable bug is found, the TesSeRact Development Team will
make every attempt to repair the bug as soon as possible. A registered
user who reports a valid bug in a release version of TesSeRact will receive
the same rights and privileges that beta testers will receive (described in
a future chapter).
Registered User License
Upon receipt of the appropriate registration fee, The TesSeRact Development
Team will license the user to use the TesSeRact Library in any and all
products that the registered user wishes. The registered user may also
distribute unregistered copies of the TesSeRact product, provided said
copies include all materials, documentation and copyright notices provided
with the original copy of TesSeRact. In addition, the embedded copyright
notice within the code may not be removed from any copy of either the
TesSeRact Library, or from an executable program that uses the TesSeRact
Library. Finally, the notices described later in this document must be
reproduced in both the source code to the registered user's product, and in
the documentation for that product.
Users of TesSeRact are requested to formally register each Ram-Resident
product with the TesSeRact Development Team. This registration is free and
allows the Development Team to maintain a list of 'available' TSR
Identification Strings. Although this registration is not required by the
terms of the software license, it is strongly recommended to avoid
conflicts of TSR names.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 3
Source Code License
In addition to the provisions described previously, upon receipt of the
appropriate fee, the TesSeRact Development Team licenses the user to use,
but NOT DISTRIBUTE, the source code to the TesSeRact Library. Registered
users may, at their option, modify the TesSeRact Library routines, with the
following exceptions:
1. The Interrupt 2Fh Multiplex Functions must not be modified in any
way that is detectable by an outside program. The modified code
must look and execute as if it was the original.
2. The embedded copyright notice, and the associated checksum code,
may not be removed.
Object modules and executable programs containing the modified TesSeRact
Library routines may be distributed without additional restrictions (other
than described previously); the source code may not be distributed in any
form, either in its original or modified form, without the express, written
permission of the TesSeRact Development Team.
Required and Suggested Notices;
Under the terms of this license, any product, either commercial, shareware,
freeware, or public domain, must include the following notice in both the
program code and the documentation (Note than an embedded copyright notice
already appears in the TesSeRact code itself; this notice should be placed
in a commented section of the code):
----------------------------------------
This product uses the TesSeRact(TM) Ram-Resident Library and supports
the TesSeRact Standard for Ram-Resident Program Communication. For
information about TesSeRact, contact the TesSeRact Development Team
at:
TesSeRact Development Team
c/o Chip Rabinowitz
2084 Woodlawn Avenue
Glenside, PA 19038
1-215-884-3373
Compuserve: 70731,20
MCIMAIL: 315-5415
This MCIMAIL Account has been provided to the TesSeRact Development
Team by Borland International, Inc. The TesSeRact Development Team is
in no way associated with Borland International, Inc. TesSeRact is a
trademark of the TesSeRact Development Team.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 4 TesSeRact(TM) Documentation (Ver. 1.00)
----------------------------------------
Products that are written to support the TesSeRact Standard which do not
use the TesSeRact Library routines are encouraged to include the following
notice in their documentation:
----------------------------------------
This product supports the TesSeRact(TM) Standard for Ram-Resident
Program Communication. For information about TesSeRact, contact the
TesSeRact Development Team at:
TesSeRact Development Team
c/o Chip Rabinowitz
2084 Woodlawn Avenue
Glenside, PA 19038
1-215-884-3373
Compuserve: 70731,20
MCIMAIL: 315-5415
This MCIMAIL Account has been provided to the TesSeRact Development
Team by Borland International, Inc. The TesSeRact Development Team is
in no way associated with Borland International, Inc. TesSeRact is a
trademark of the TesSeRact Development Team.
----------------------------------------
Developers who have special circumstances which would appear to violate a
portion or portions of the TesSeRact License Agreement are urged to contact
the TesSeRact Development Team to work out details of a special license.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 5
Chapter 2. Shareware Terms
TesSeRact is a user-supported program, also known as 'shareware.' You are
permitted under the terms of this license to use this software for 30 days
without any payments. If you continue to use this software past this
point, you must register your copy as outlined below.
Registration for the TesSeRact Library, in any form, is a one-time fee of
$25. Payment of this fee entitles you to:
1. A disk with the latest version of the TesSeRact Library.
2. Printed Documentation
3. The right to use the TesSeRact Library with any Ram-Resident
program you sell or distribute, provided the appropriate
copyright notices appear in your code and documentation.
4. Upgrades to future versions of TesSeRact for $10.
The complete, commented source code to TesSeRact is also available to
registered users only for a fee of $25.
For an additional $10 per year, registered users can receive a monthly
newsletter consisting of a list of all registered products, their
associated TSR Identification Strings, and level of support of the
TesSeRact Ram-Resident Program Communication Standard. This newsletter
will also contain information about new versions of TesSeRact, supported
languages, new documentation, etc.
Users who wish to 'test-drive' TesSeRact may do so for a period of 30 days
without charge. The TesSeRact Library and Documentation are available on
many electronic bulletin boards, commercial electronic networks, and mail
order 'distribution' houses. If you do not have access to any of these
methods, the TesSeRact Development Team will send you a copy of the Library
and disk-based documentation for $10. The disk-based documentation differs
from the printed documentation only in formatting -- the content is
identical.
Developers who have special circumstances which would appear to violate a
portion or portions of the TesSeRact License Agreement are urged to contact
the TesSeRact Development Team to work out details of a special license.
Registered users of TesSeRact are requested to formally register each Ram-
Resident product with the TesSeRact Development Team. This registration is
free and allows us to maintain a list of 'available' TSR Identification
Strings. Although this registration is not required by the terms of the
software license, it is strongly recommended to avoid conflicts of TSR
names. Registered products will be printed in the monthly newsletter.
Persons interested in testing future versions of TesSeRact should contact
the TesSeRact Development Team for information. Registered testers who
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 6 TesSeRact(TM) Documentation (Ver. 1.00)
report verifiable bugs or who make enhancement suggestions that are
implemented in TesSeRact receive an automatic registration to either the
current or next version of TesSeRact; or a freesource code license.
Developers are also encouraged to include Chapter 10 of this document,
entitled 'Communicating with the TesSeRact,' with any or all of their
program documentation. Chapter 11, 'Writing TesSeRact-Compatible
Programs,' is also suitable for reproduction. These chapters, with the
appropriate copyright notices intact may be reproduced without fee for the
purpose of promoting the TesSeRact Standard.
Technical Support
Technical Support for TesSeRact is provided free of charge in Subtopic 13
of the Computer Language Magazine Forum (GO CLMFOR) on CompuServe
Information Service. This is the ONLY official electronic location for
TesSeRact technical support, although asking a question almost anywhere on
CompuServe will get an answer. Technical Support will NOT be provided via
MCIMAIL or CompuServe Easyplex Mail.
Members of the TesSeRact Development Team may, at their option, be
available for lectures and seminars on the product. Please do not contact
them directly -- forward such requests to the official address of the
development team listed above, or via electronic means.
Prepared programs currently exist for a one-to-two hour TesSeRact
'introduction' seminar, as well as for a full-day Workshop for developing
applications with TesSeRact. These programs were designed by the TesSeRact
Team Leader; Users Groups, Colleges, or Corporations interested in such
programs should contact the Development Team.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 7
Association of Shareware Professionals
The Team Leader of the TesSeRact Development Team is a member of the
Association of Shareware Professionals (ASP), an organization formed in
April 1987 to strengthen the future of shareware (user supported software)
as an alternative to commercial software. Its members, all of whom are
programmers who subscribe to a code of ethics, are committed to the concept
of shareware as a method of marketing.
The primary goals of the ASP are:
To inform users about shareware programs and about shareware as a
method of distributing and marketing software;
To encourage broader distribution of shareware through user groups and
disk dealers who agree to identify and explain the nature of
shareware;
To assist members in marketing their software;
To provide a forum through which ASP members may communicate, share
ideas, and learn from each other; and
To foster a high degree of professionalism among shareware authors by
setting programming, marketing and support standards for ASP
members to follow.
Standards for the Association of Shareware Professionals
PROGRAMMING STANDARDS:
The program meets the ASP's definition of "shareware" (i.e., it is not
a commercial demo with major feature disabled, nor a time-limited
program).
The program has been thoroughly tested by the author and should not be
harmful to other files or hardware if used properly.
DOCUMENTATION STANDARDS:
Sufficient documentation is provided to allow the average user to try
all the major functions of the program.
Any discussion of the shareware concept and of registration
requirements is done in a professional and positive manner.
SUPPORT STANDARDS:
The member will respond to people who send registration payments, as
promised in the program's documentation. At a minimum, the
member will acknowledge receipt of all payments.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 8 TesSeRact(TM) Documentation (Ver. 1.00)
The member will establish a procedure for users to report, and have
acknowledged, matters such as bug reports, and will describe such
means in the documentation accompanying all versions of the
programs. The author will respond to written bug reports from
registered users when the user provides a self-addressed, stamped
envelope.
Known incompatibilities with other software or hardware and major or
unusual program limitations are noted in the documentation that
comes with the shareware (evaluation) program.
GENERAL:
Members will keep the ASP apprised of changes in mailing address;
which shareware programs they have published and are currently
supporting; the current version numbers; and of any changes in
the status of their programs.
If a user has a dispute with an ASP member-author, the user may appeal
to the ASP to mediate for arbitration of the dispute.
For more information about the Association of Shareware Professionals,
contact Jim Button, chairman of the board of directors, at Compuserve
71435,2012.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 9
Order Form
TesSeRact(TM) Products And Registration Form
Name: ______________________________________
Address: ______________________________________
______________________________________
City: ______________________________________
State: __________________________ Zip: ______
Telephone: ______________________________________
Primary Language: _________________________________
Item Quantity Total
--------------------------------------------------------------
TesSeRact Registration ($25 each)___________________|_________
TesSeRact Source Code License ($25 each)____________|_________
TesSeRact Trial Disk ($10)__________________________|_________
Monthly Information NewsLetter______________________|_________
($10 per year)
Product Identification String (Free!!)______________|_________
Your ID String: _____________________
Product Name: _____________________
--------------------------------------------------------------
Total Due: |_________
Preferred Disk Size: 3.5" ____ 5.25" ____
Mail Completed Form to:
TesSeRact Development Team
2084 Woodlawn Avenue
Glenside, PA 19038
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 10 TesSeRact(TM) Documentation (Ver. 1.00)
Chapter 3. History of TesSeRact and the Development Team
The TesSeRact Development Team was organized in early 1986 as the
Ringmaster Development Team for the sole purpose of establishing a standard
to be shared by TSR program developers, in hopes of reducing the notorious
levels of conflict between such programs. Participants (all listed earlier
in this document) represented the majority of leading independent TSR
developers. From the start, the team conducted its discussions using the
CompuServe Information System; it originally met in a restricted area of
IBMNET and subsequently moved to the CLMFORUM for public beta tests of the
libraries.
The team's original goals were lofty; too much so, perhaps, to be
achievable within a reasonable time span. The team envisioned a total
Applications Program Interface (API) for use by both independent and
commercial TSR programs. Although discussions with a leading software
publisher were held, a consensus developed that no such universal API could
gain acceptance. After that conclusion was reached, active participation
dwindled with the passage of time, and at one point it appeared to nearly
everyone as if the project had died. Establishment of a public discussion
area for TSR techniques on the old MSOFT forum breathed new life into the
effort and brought fresh contributions from Thomas Brandenborg and John
Hensley. As a result of that discussion, the activity revived with a more
limited goal of providing a simplified method for creation of TSR programs
using high level languages and a standard interface for communicating with
such programs.
The present package is the outcome of that revived research. Although most
of the original team members did not participate in the development of the
current product, their efforts were vital to the TesSeRact library routines
and Standard. Development continues, and the original goal of a universal
API remains faintly visible on the horizon as a rainbow to be chased. In
the meantime, TesSeRact as it exists today provides a usable, and we hope,
useful tool to the TSR development community.
Future plans for TesSeRact include support for Expanded and Extended
Memory, and of course, new and improved future versions of DOS. If support
for the TesSeRact interface is strong enough, we plan to develop a version
that will run in protected mode as a keyboard monitor under OS/2.
In addition, if there is enough support, the TesSeRact Development Team
would like to become the 'clearinghouse' for TSR program development,
studying options and continuing to delve into undocumented features of
operating systems for the PC.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 11
Chapter 4. TesSeRact Data Structures and Variables
A Quick Note about Graphics Modes
Although TesSeRact does not support changing video modes (with one
exception described below) for resident programs, there are three functions
TesSeRact DOES provide to simplify how a TSR interfaces with the multitude
of graphics cards available.
First, a developer can specify NOPOPGRAPH (see below) as one of the
parameters to TsDoInit(). This forces the TesSeRact popup routines to
check to see if the current video mode is 0, 1, 2, 3 or 7. If the video
mode returned by Interrupt 10h is not equal to the five standard 'text
modes,' then TesSeRact will issue a TessBeep() function call, and return.
The second feature TesSeRact provides is detection of Hercules graphics
modes. If the video mode returned by Interrupt 10h is 7, a check is also
made for the presence of a Hercules Graphics Card (or compatible) adapter.
If the HGC is present, and the current mode (using routines supplied by
Hercules) is graphics, the TesSeRact routines will issue a TessBeep()
function call and return to the underlying application, just as if an
invalid video mode was detected.
There is one exception to this rule. If NOPOPGRAPH is specified and a
graphics mode is detected, a special flag is checked to determine if the
underlying application is Microsoft Word Version 4.0. If it is, TesSeRact
sends an Alt-F9 character to the keyboard buffer and returns, causing Word
to switch into text mode, if possible. TesSeRact then delays a full two
seconds and pops up. If Word was unable to switch to text mode (using
high-resolution graphics mode on a Herc card, for example), TesSeRact beeps
and returns.
The third and final provision TesSeRact makes for graphics modes is by
setting two variables on popup: _TESS_VIDPAGE and _TESS_VIDMODE. These
variables (one byte each) are set to the values returned by the Interrupt
10h call to get the video mode. If a Hercules card is detected and it is
in graphics mode, then both of these variables are set to 0FFh.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 12 TesSeRact(TM) Documentation (Ver. 1.00)
TesSeRact Data Structures
There are four primary data structures used by the TesSeRact Library
Routines: TsrIntTable, ExtraHot, TsrData, and TsrParms. Each is described
in detail below. Note these structures are shown in C language style (from
TESS.H). TESS.INC (for assembler) and TESS.TP4 (for Turbo Pascal) have
descriptions of these structures for use with other languages.
TsrIntTable
struct TsrIntTable {
void far * OldVector; /* Old Interrupt Vector */
unsigned char IntNumber; /* Interrupt Number */
void near * NewVector; /* offset of new vector */
};
The TsrIntTable structure is used internally by the two TesSeRact
functions, _TESSSETUPINTS and _TESSRESTOREINTS. These are the functions
used to save/restore the interrupt vectors TesSeRact uses. All occurrences
of this structure are inside the TsrData structure described below.
ExtraHot
struct ExtraHot {
unsigned char Hotkey; /* hotkey to check for */
unsigned char ShiftState; /* shift state for this hot key */
unsigned char FlagByte; /* flag value to use */
/* MAY NOT BE ZERO!!! */
};
The ExtraHot structure used by the TsSetExtraHot() function is described
above. This data area is stored within the USER data area, and the
TesSeRact interrupt handlers only reference this information through a FAR
pointer, stored in the TsrParms structure. Please note that the FlagByte
may not be zero -- that value is reserved for the PRIMARY hotkey
combination, which is set up by the call to TsDoInit().
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 13
TsrData
struct TsrData { /* PUBLIC Symbol TESS_GLOBALS */
unsigned char RevLvl; /* Revision Level of TESS Lib */
unsigned char PopupType; /* Type of popup in effect */
unsigned char WasInt8; /* An Interrupt 08h occurred */
unsigned char WasInt13; /* An Interrupt 13h occurred */
unsigned char IntFlags; /* Which interrupts are active */
unsigned char SoftFlags; /* Which soft ints are active */
unsigned char DosVersion; /* Current major revision of DOS */
unsigned char waitcount; /* Count to wait before popping up */
void far * InDosFlag; /* Pointer to DOS INDOS flag */
void far * DosCritErr; /* Pointer to DOS Critical Error */
unsigned short UserPSP; /* PSP segment of user program */
unsigned short User28PSP; /* PSP segment of user program */
void far * UserDTA; /* DTA of interrupted program */
void far * User28DTA; /* DTA of interrupted program */
unsigned short UserSS; /* Stack segment of user program */
unsigned short UserSP; /* Stack pointer of user program */
unsigned short User28SS; /* Stack segment of user program */
unsigned short User28SP; /* Stack pointer of user program */
void far * UserInt24; /* Pointer to use INT 24 handler */
unsigned short OldExtErr[3]; /* Storage for old DOS 3 extended */
/* error information */
unsigned char OldBreak; /* Old Break Setting */
unsigned char OldVerify; /* Old Verify Setting */
unsigned char InWord4; /* Flag to indicate in WORD 4.0 */
unsigned char WasWord4; /* Word 4 special popup flag */
unsigned char NewKbdFlag; /* Enhanced Keyboard Call in use */
unsigned char Word4Delay; /* Delay for Word 4 */
/* Interrupt vector tables */
struct TsrIntTable Int8;
struct TsrIntTable Int9;
struct TsrIntTable Int13;
struct TsrIntTable Int16;
struct TsrIntTable Int1C;
struct TsrIntTable Int21;
struct TsrIntTable Int28;
struct TsrIntTable Int2F;
struct TsrIntTable Int1B;
struct TsrIntTable Int23;
struct TsrIntTable Int24;
};
The TsrData structure holds virtually all the data used by TesSeRact. For
the most part none of these should be modified by an application program.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 14 TesSeRact(TM) Documentation (Ver. 1.00)
RevLvl is always 1 for this release of TesSeRact. PopupType stores the
current state of the INDOS flag when the _TESSDOPOPUP routine is called.
Just about the only time this flag is set on entry to TsrMain() is when
sitting at the DOS prompt. Some TSR's need to react differently in this
case (such as TSR's that spawn other applications), so this information is
made available.
The WasInt8 and WasInt13 bytes may be used to detect if a timer tick or a
disk interrupt occurred. The TesSeRact interrupt routines only SET these
flags -- never clear them -- so their use is totally up to the individual
program developer. (See the TESSPARK assembler demonstration program for
possible uses for these flags.)
IntFlags and SoftFlags are used by the TesSeRact routines to determine
which interrupts are currently being executed (see definitions for these
values in the section on "equates," below). They should never be modified
by an application program.
DosVersion stores the current MAJOR version of DOS (2, 3, etc.). waitcount
is used internally by the popup routines to delay if INDOS is set -- some
programs call DOS in their own Idle loop, and the delay used by TesSeRact
(eight timer ticks) appears to be sufficient to ensure popup.
The next two pointers, InDosFlag and DosCritErr, point to data areas inside
DOS. The INDOS flag is a byte signifying whether an Interrupt 21h function
is active, and the Critical Error is normally zero, unless DOS is
currently servicing an Interrupt 24h (critical error) request.
Next come a number of storage areas that are fairly self-explanatory. The
variables with '28' in their name are used by the background procedures,
and the others are used by the popup procedures.
UserInt24 is a far pointer (normally set to 0) to a user-defined Interrupt
24h handler. This value is set when a user calls the TsSetUser24()
function (TesSeRact Multiplex Function 03h).
The OldExtErr, OldBreak and OldVerify areas are used to store information
during popup, and the InWord4, WasWord4, and Word4Delay variables are used
by the popup routines for the special graphics 'flip' described above. The
NewKbdFlag variable is generally 0 -- however, if an application program
calls one of the 'extended' keyboard functions (Interrupt 16h, Functions
10h, 11h or 12h), this byte gets set to 10h during the interrupt call.
At the end of this structure are the interrupt tables used by TesSeRact
routines.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 15
TsrParms
struct TsrParms { /* PUBLIC Symbol TESS_USERPARMS */
char IdCode[8]; /* Unique TSR Identification String*/
/* NOTE -- NOT NULL-TERMINATED */
unsigned short IdNum; /* Unique TSR Identification Number*/
unsigned long FuncFlags; /* Bit map of supported functions */
unsigned char HotKey; /* Hotkey used by TSR for popup */
unsigned char ShiftState; /* ShiftState used by this TSR pop */
unsigned char HotKeyFlag; /* Which hotkey is in use */
unsigned char ExtraHotCount; /* Number of Extra Hotkeys to use */
void far * ExtraHotKeys; /* Pointer to extra hotkeys */
unsigned short TsrStatus; /* Current TSR Status Flags */
unsigned short TsrPSP; /* TSR's PSP Segment */
void far * TsrDTA; /* Pointer to TSR's DTA region */
unsigned short TsrDSeg; /* TSR's Default Data Segment */
void far * PopupStack; /* Pointer to Popup Stack Area */
void far * BackStack; /* Pointer to Background Stack */
};
The TsrParms structure is used to store information about the TSR that is
necessary for hotkey detection and popup control. All of the information
in this structure is placed there by the TesSeRact initialization routines
-- users should not directly write into this area except under controlled
circumstances and under VERY controlled conditions. For the most part,
these variables are self-explanatory, but some comments are in order.
The IdCode area is eight bytes long -- with no null-terminator required and
no length byte (as used by Pascal). Eight bytes are copied from the string
passed during TsCheckResident(). IT IS ABSOLUTELY VITAL THAT THE
IDENTIFICATION STRING BE PADDED TO A MINIMUM OF EIGHT BYTES!!! If the
identification string is less than eight bytes, your TSR will not be able
to find itself in memory! Please note that the IdNum is assigned based on
the number of other TesSeRact-aware programs currently installed in the
system.
FuncFlags is a bit-mapped, four-byte variable that describes which
TesSeRact Multiplex Functions are supported by this TSR. For all programs
written using the TesSeRact Library, this is (hex) FFFFFFFF. Developers of
programs that support the TesSeRact Standard should use this double-word to
identify which Multiplex functions they support (for more details, see
Chapter 11).
HotKey and ShiftState are used in combination to determine when the program
should call TsrMain(). If your program does not use a popup, set both of
these values to Hex 0FFh on the call to TsDoInit(). Do not set HotKey to
ZERO -- this signifies that the program is to pop up when the current shift
states match the value of ShiftState, without checking for a hotkey value.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 16 TesSeRact(TM) Documentation (Ver. 1.00)
The correct value for HotKey is the Scan Code (listed in Appendix B) of the
key -- not the value returned by Interrupt 16h.
The HotKeyFlag byte may be used by a program to determine which hotkey the
user hit (if extra keys are set with TsSetExtraHot()). This value is ZERO
if the primary hotkey was used; otherwise, this is set to the FlagByte
specified for the appropriate hotkey in the ExtraHotKeys array.
The ExtraHotCount tells TesSeRact how many 'extra' hotkeys are used. These
hotkeys are stored in an array of ExtraHot structures; TsSetExtraHot()
receives a pointer to this array, and stores it here.
The TsrStatus flag word is a bit-mapped value described in more detail in
the description of the various equates below.
Other PUBLIC, Global Variables
newint?? /* TesSeRact Interrupt Vectors */
_TESS_ENDOFDATA /* Top of TesSeRact Data Area */
/* Beginning of Copyright Notice */
_TESS_CPYRT /* Second Part of Copyright Notice */
_TESS_VIDMODE /* Video Mode when TsrMain() called*/
_TESS_VIDPAGE /* Video Page when TsrMain() called*/
_TESS_INTERRUPTRETURN /* Dummy 'IRET' instruction */
_TESS_ERROR24 /* Interrupt 24h Error Code */
_TESS_TEMPPARMS /* Temporary Data Storage Location */
The variables described above are other PUBLIC symbols available. The
newint?? variables point to TesSeRact's interrupt handlers.
_TESS_ENDOFDATA is the end of TesSeRact's internal data, and the beginning
of the copyright notice. _TESS_CPYRT is a pointer to the second part of
the copyright notice.
_TESS_VIDMODE and _TESS_VIDPAGE are used to store the current video mode
information on entry to TsrMain() and are described in more detail earlier.
_TESS_INTERRUPTRETURN is used by the POPFF macro to avoid the problems that
can be caused by the infamous 'popf' bug on early 80286 chips.
_TESS_ERROR24 is used by TesSeRact's default Interrupt 24h handler to store
the error code passed by DOS, and _TESS_TEMPPARMS is used for some
temporary data storage.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 17
Equates and Definitions
Shift State and hotkey flags
TSRHOT_?? /* Definitions for (scan code) */
TSRPOP??? /* Definitions for shift state */
Appendix B Lists equates for various scan codes and shift states that can
be used by TesSeRact programs for calling TsDoInit() and TsSetExtraHot().
These definitions are included in TESS.H, TESS.INC and TESS.TP4.
TsrFlags
TSRUSEPOPUP /* User Requests Popup Routine */
TSRUSEBACK /* User Requests Background Routine*/
TSRUSETIMER /* User Requests Timer Routine */
TSRUSEUSER /* User Requests User Procedure */
NOPOPGRAPH /* User Requests No Pop on Graphics*/
NOPOPCOMMAND /* User Requests No Pop if INDOS==1*/
These equates, described in the various include files, are used for the
TsrFlags parameter in the call to TsDoInit(). These values are bit-mapped
and correspond directly to the equates described below for the bit-mapped
values of TsrStatus.
TsrStatus
HOTKEYON /* Hotkey pressed */
SHIFTSON /* Shift states match */
TSRACTIVE /* TSR is running in foreground */
INT28ACTIVE /* Background routine is active */
POPUPSET /* Popup resident routine installed*/
BACKSET /* Background routine installed */
TIMERSET /* Timer procedure installed */
EXTRAHOTSET /* Extra hot keys installed */
USERPROCON /* User-defined procedure installed*/
TSRENABLED /* TSR currently enabled */
TSRRELEASED /* TSR has been released */
EXTRAINT24 /* User installed replacement INT24*/
These equates describe the bit-mapped contents of the TsrStatus flag word.
The actual equates are described in more detail in each include file.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 18 TesSeRact(TM) Documentation (Ver. 1.00)
Chapter 5. TesSeRact External Functions
The routines described in this chapter are REQUIRED user entry points
called by the TesSeRact Library Routines. If you are using the TP4 Unit,
the TsSetAdrTP4 procedure must be called with appropriate flags for EVERY
function you intend to use. Unused functions are initialized by the Unit
to point to far returns. (See Chapter 10 for a complete description of
TsSetAdrTP4.) Users of the C Library should note that there are dummy
functions for each of these routines in the library (users of Microsoft
LINK should use the '/NOE' linker option) -- it is only necessary to
include those routines in your that you actually intend to use. Users of
the assembler version MUST have an entry point for each of these PUBLIC
symbols; at a minimum, these entry points must have a NEAR return.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 19
TsrMain -- Entry Point for Popup Routine
This is the main entry point for your TSR procedure. If you specify
TSRUSEPOPUP for the TsrFlags parameter, this routine is called
whenever your Shift State and HotKey are pressed. (Note that if
extra hotkeys are specified using the TsSetExtraHot() function, the
ExtraHotCount byte of the TsrParms data area is set to the
appropriate value for the hotkey selected.) On entry to this
routine, DS and ES are the default data segment for your program;
all other registers are undefined. The PSP and DTA have been set
up for your application, and it is safe to call any runtime library
functions as long as your application uses the 'default' stack, or
avoids functions with built-in stack-checking (see other discussion
about stack-checking in the description of TsSetStack()), as well
as any DOS functions. Note that ^C and ^Break are COMPLETELY
disabled while this routine is in action. The scan codes are
intercepted by the TesSeRact Keyboard handler and prevented from
ever reaching the BIOS or DOS.
Parameters:
None.
Returns:
None.
C Language Usage:
void far pascal TsrMain(void);
Pascal Usage:
{$F+} PROCEDURE TsrMain; {$F-}
Assembler Usage:
PUBLIC TSRMAIN
TSRMAIN proc near
ret
TSRMAIN endp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 20 TesSeRact(TM) Documentation (Ver. 1.00)
TsrBackCheck -- Check to see if background processing is requested
This function is a simple one -- and should be as small as possible.
The purpose of this routine is to check appropriate status flags to
determine if background processing is needed. This is user-
specific, but the following guidelines should be taken into
account: this routine is called when it is safe to interrupt DOS,
but the stack is the DOS stack, so C Runtime Routines should not be
used. The DS and ES registers point to your default data segment,
so it is possible to access your own data; you may also call BIOS
and DOS functions safely (at some point, a full list of safe DOS
functions may be available -- at the present time, we know of none
that do NOT work here). As mentioned above, the primary purpose of
this routine is to check and see if full background processing is
needed. If so, a non-zero value is returned; otherwise, a value of
zero is returned. If non-zero, the TsrBackProc() procedure is
called immediately. TSRUSEBACK must be set for this function to be
called.
Parameters:
None.
Returns:
Zero signals no background processing is desired
Non-Zero results in immediate call to TsrBackProc
C Language Usage:
unsigned far pascal TsrBackCheck(void);
Pascal Usage:
{$F+} FUNCTION TsrBackCheck : word; {$F-}
Assembler Usage:
PUBLIC TSRBACKCHECK
TSRBACKCHECK proc near
mov ax,word ptr ShouldProcess ;0 if no
background, 1 for
ret ; background processing
TSRBACKCHECK endp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 21
TsrBackProc -- Background Processing Procedure
This function is called if TsrBackCheck() returns a non-zero value.
It is safe to call the C Runtimes, DOS, and virtually anything you
want. On entry, ES and DS point to your default Data Segment; you
are operating on the stack you specified for background operations,
the PSP and DTA are yours, and all the DOS status has been saved.
Processing here can be identical to TsrMain() processing, except
that this interrupt occurs asynchronously, rather than as the
result of a hotkey.
Parameters:
None.
Returns:
None.
C Language Usage:
void far pascal TsrBackProc(void);
Pascal Usage:
{$F+} PROCEDURE TsrBackProc; {$F-}
Assembler Usage:
PUBLIC TSRBACKPROC
TSRBACKPROC proc near
ret
TSRBACKPROC endp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 22 TesSeRact(TM) Documentation (Ver. 1.00)
TsrTimerProc -- Periodic Timer Procedure
This function is called approximately 18.2 times per second (unless
the routine takes too long -- reentrancy is not permitted). The DS
and ES registers point to your default data segment, but no other
modifications are made -- you are operating off of the stack that
was interrupted by the Interrupt 08h Timer Tick. DOS functions and
Runtime functions are generally not safe, so be careful. This
routine should be as small and fast as possible in order to receive
the maximum number of ticks from the processor and avoid slowing
down other background operations.
"Too long" is very subjective. It completely depends on the hardware
being used and other factors that can hurt interrupt latency. In
general, spend as little time as possible in this procedure.
Parameters:
None.
Returns:
None.
C Language Usage:
void far pascal TsrTimerProc(void);
Pascal Usage:
{$F+} PROCEDURE TsrTimerProc; {$F-}
Assembler Usage:
PUBLIC TSRTIMERPROC
TSRTIMERPROC proc near
ret
TSRTIMERPROC endp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 23
TsrUserProc -- Interface for External Processing
This function is designed to allow an external program or procedure to
interface with your TSR. You receive DS (in the non-assembler
version, ES=DS as well) pointing to your data segment, and SS is
the Background Stack. If a call to TsrBackProc() is currently
being processed when an application calls this function, the
TesSeRact functions loop until the background stack is free. This
is generally used for inter-process communication between
applications. This routine is called when a program issues
TesSeRact Multiplex Function 20h.
Note that the PSP in effect when TsrUserProc() is called is the PSP
belonging to the CALLER, not the PSP of the TSR. Although it is
safe to use DOS functions, the TSR's file handle table and other
PSP data areas are not available.
Parameters:
UserPtr..................FAR pointer to user-defined data
Returns:
None.
C Language Usage:
void far pascal TsrUserProc( void far *UserPtr);
Pascal Usage:
{$F+} PROCEDURE TsrUserProc( UserPtr : pointer ); {$F-}
Assembler Usage:
PUBLIC TSRUSERPROC
TSRUSERPROC proc near
;
; ES:DI contains FAR pointer to user data
;
ret
TSRUSERPROC endp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 24 TesSeRact(TM) Documentation (Ver. 1.00)
TsrCleanUp -- Initialize or Clean Up TSR
This function is called by the TesSeRact routines to tell the TSR that
it is initializing or releasing. On entry, DS and ES is set to the
correct segment, and SS:SP is set to the stack pointer UNLESS it
is already set correctly (for example, the first time this routine
is called, from inside TsDoInit(), the stack is correct, so it is
not adjusted). It is safe to call DOS from inside this routine.
The initialization portion of this procedure should be used to call
'configuring' functions, such as TsSetExtraHot() or other TesSeRact
Multiplex Functions that cannot be called until the Interrupt
Handlers have been installed. The shutdown procedure should be
used to close any open files and call the high-level language exit
procedures. (NOTE: TP4s exit procedures are called from within
TESSTP.TPU.)
Parameters:
InitOrShutdown...........0 = Initialize, 1 = ShutDown
Returns:
None.
C Language Usage:
void far pascal TsrCleanUp(unsigned InitOrShutdown);
Pascal Usage:
{$F+} PROCEDURE TsrCleanUp ( RemoveTSR : Boolean ); {$F-}
Assembler Usage:
PUBLIC TSRCLEANUP
TSRCLEANUP proc near
;
; on entry, AX contains the initialize or shutdown flag
or ax,ax
jz do_init
do_release:
....
jmp cleanup_exit
do_init:
....
cleanup_exit:
ret
TSRCLEANUP endp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 25
Chapter 6. TesSeRact Library Routines
The TesSeRact Library Routines described in this chapter are the functions
a program should call before going resident. They are presented in the
order in which they should be called: TsSetStack(), TsCheckResident(),
then TsDoInit(). TsVerify2F() and TessBeep() are utility functions also
included in this chapter.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 26 TesSeRact(TM) Documentation (Ver. 1.00)
TsSetStack -- Sets stacks to be used by resident routines
This function tells the TesSeRact functions what data areas to use as
stacks. A value of NULL for the PopUpStack parameter means to use
the current (default) stack segment and stack pointer of the
application that calls this function. If you use NULL for the
PopUpStack, this should be the first call inside main(), and you
should use as few local variables in main() as possible to allow
the use of the maximum amount of stack. Do not specify a value of
NULL for the BackGroundStack parameter unless you do not have a
background procedure. To use the C or Pascal runtime routines
within your TSR, you should use stacks of AT LEAST 2K. Also, all
high-level language users should note that unless the default stack
is used, stack-checking will fail. Many routines in the standard
runtime libraries provided with Turbo C, Microsoft C and Turbo
Pascal have been compiled with stack-checking enabled (printf() is
a good example) and will FAIL unless the stack is within the limits
defined by the runtime library. The demonstration programs show
example code (using undocumented variables) of how to 'split' the
default stack. Please note that with Microsoft C, it is not
possible to directly set the size of the default stack from within
the program -- this must be done with the EXEMOD program (or the
/STACK option to LINK) in order to enlarge the stack.
Parameters:
PopUpStack...............Pointer to Stack for PopUp Procedure
BackGroundStack..........Pointer to Stack for Background Procedure
Returns:
None.
C Language Usage:
extern void far pascal TsSetStack(
void far * PopUpStack,
void far * BackGroundStack
);
Pascal Usage:
procedure TsSetStack(
var PopUpStack,
BackGroundStack
);
(continued)
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 27
Assembler Usage:
EXTRN TSSETSTACK:NEAR
mov di,offset PopUpStack
mov si,offset BackGroundStack
call TSSETSTACK
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 28 TesSeRact(TM) Documentation (Ver. 1.00)
TsCheckResident -- Determine if program has been loaded
This function serves two primary purposes. First, it checks to make
sure that the program identified by the passed IDStr has not
previously been loaded. Then it begins setting up the TesSeRact
data structures for this TSR, in preparation for a call to
TsDoInit(). Programs that will not go resident may either use this
function call or may call the TesSeRact Multiplex Function (00h)
directly.
Parameters:
IDStr....................Pointer to unique 8-byte Identification
String for this program. ALL EIGHT bytes
are significant when comparing strings!
IDNum....................Pointer to WORD (two-byte) data location
where returned TSR Identification Number
will be placed.
Returns:
FFFFh indicates the TSR has already been loaded and may be identified
by the Identification Number returned in IDNUM.
0 (zero) indicates the specified TSR was not found and a new TSR may
be installed using the Identification Number returned in IDNUM.
If this function returns FFFFh, and the high byte of IDNUM is FFh, it
signifies that the TSR has previously been loaded, but has a 'release'
command pending. This TSR may be restarted with the TsRestart()
function, or TesSeRact Multiplex Function 13h.
C Language Usage:
extern unsigned far pascal TsCheckResident(
char far * IDStr,
unsigned far * IDNum
);
Pascal Usage:
function TsCheckResident(
var IDStr,
IDNum
) : word;
(continued)
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 29
Assembler Usage:
EXTRN TSCHECKRESIDENT:NEAR
push cs
pop es
mov si, offset IdStr
mov di, offset IdNum
call TSRCHECKRESIDENT
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 30 TesSeRact(TM) Documentation (Ver. 1.00)
TsDoInit -- Initializes variables and goes resident
This function initializes the TSR variables and 'goes resident' with
the amount of memory you specify and initializes the flags for user
routines that you specify.
Parameters:
HotKey...................Scan Code of Key to use as HotKey (see
Appendix B)
ShiftState...............Shift State to be used in combination with
HotKey
TsrFlags.................Which Routines are enabled (see Chapter 4)
MemoryTop................Number of 16-byte Memory Paragraphs to
keep resident (in the ASM version, this is
the offset of the top of program's memory
that will be kept resident)
Returns:
Should NEVER return, unless DOS' INDOS flag or Critical Error Flag
could not be found, in which case the return value is 0xFFFF
C Language Usage:
extern unsigned far pascal TsDoInit(
unsigned char HotKey,
unsigned char ShiftState,
unsigned short TsrFlags,
unsigned short MemoryTop
);
Pascal Usage:
function TsDoInit(
HotKey,
ShiftState,
TsrFlags,
MemoryTop : word
) : word;
(continued)
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 31
Assembler Usage:
EXTRN TSDOINIT:NEAR
mov ah, HotKey
mov al, ShiftState
mov bx, TsrFlags
mov dx, offset MemoryTop
call TSDOINIT
;
;Remember that this function ONLY returns on an error
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 32 TesSeRact(TM) Documentation (Ver. 1.00)
TsVerify2F -- Verify Interrupt 2Fh has valid handler
This function is called internally by TsCheckResident() and is used to
ensure that the existing Interrupt 2Fh handler is valid. This
function is only needed under DOS versions 2.x -- beginning with
version 3.0, DOS pointed this interrupt vector to an IRET
instruction. It is only necessary to call this function if an
application is not using the TsCheckResident() library routine.
Parameters:
None.
Returns:
None.
C Language Usage:
extern void far TsVerify2F(void);
Pascal Usage:
procedure TsVerify2F;
Assembler Usage:
EXTRN TSVERIFY2F:NEAR
call TSVERIFY2F
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 33
TessBeep -- Call TesSeRact Internal Beep Routine
This function is used to allow a routine to call the same BEEP
procedure used by TesSeRact when it is unable to popup. In the
assembler version of TesSeRact, TessBeep() is provided in a
separate OBJ module so that it may be completely replaced by a
user-defined procedure. In the C Library, TessBeep() is in the
TSDOBEEP module and also may be replaced by the user.
Parameters:
None.
Returns:
None.
C Language Usage:
extern void far pascal TessBeep(void);
Pascal Usage:
procedure TessBeep;
Assembler Usage:
EXTRN TESSBEEP:near
call TESSBEEP
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 34 TesSeRact(TM) Documentation (Ver. 1.00)
Chapter 7. TesSeRact Multiplex Functions
These functions may be accessed in one of two ways: First, by calling the
library routine described below directly (this is not available in the
assembler version). Second, by calling the appropriate Interrupt 2Fh
Multiplex Function call, as described below.
Initialization and Information Routines
The initialization and information routines are designed to be called by a
TSR during the initialization portion. The Check Install function may be
used instead of the TsCheckResident() Library Routine described in Chapter
6. The ONLY Multiplex Functions that may be called BEFORE TsDoInit() is
Check Install or Check Hotkey. The other functions in this section should
be called from inside the TsrCleanUp() procedure (initialization portion).
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 35
Check Install (Function 00h)
This function must be called before TsDoInit(). It checks to see if
this TSR has already been loaded by comparing the passed IDStr with
other compatible TSRs. The primary difference between Check
Install and TsCheckResident() is that Check Install does no
initialization of internal data structures, and should ONLY be used
by a program to FIND a TSR in memory and get its handle -- NOT to
determine if the TSR you are trying to install has already been
loaded. Please note that under DOS versions 2.x, the Interrupt 2Fh
vector is initialized to ZERO -- a program calling Interrupt 2Fh
will cause the machine to crash if a TesSeRact TSR has not been
loaded. TsVerify2F() should be called prior to calling this
function, or the application should make its own check for the
validity of Interrupt 2Fh.
Parameters:
IDStr....................Pointer to unique 8-byte ID String for
this program. All eight bytes are
significant when comparing strings, so
make sure you specify the values for ALL
eight bytes.
Returns:
AX=0FFFFh indicates the TSR has already been loaded, and may be
identified by the ID Number returned in the CX register.
Any other value for AX indicates that it is safe to install this TSR,
using the identification number returned in the CX register.
C Language Usage:
See Assembler Usage.
Pascal Usage:
See Assembler Usage.
Assembler Usage:
mov ax,5453h
mov si,offset IDStr
xor cx,cx
xor bx,bx
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 36 TesSeRact(TM) Documentation (Ver. 1.00)
Return User Parameter Pointer (Function 01h)
This function returns a pointer to the specified TSR's parameter
block. This block contains important information about the TSR.
The structure is described in detail in Chapter 4 as the TsrParms
structure. Note that other TesSeRact Multiplex Functions provide
information that is also available from the data contained in this
structure; they are designed to be used as an alternative method
for getting information about the TSR.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
NULL = No Matching TSR ID Number found
Otherwise, FAR pointer to TsrParms structure
C Language Usage:
extern struct TsrParms far * far pascal TsGetParms(
unsigned short TsrIdNum
);
Pascal Usage:
function TsGetParms(
TsrIdNum : word
) : ParmPtr;
Assembler Usage:
mov ax,5453h
mov bx,01h
mov cx,TsrIdNum
int 2fh
or ax,ax
jnz not_found
;
; Pointer to data returned in ES:BX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 37
Check Hotkey (Function 02h)
This function is used to determine if the selected hotkey is not in
use by any other TesSeRact-compatible TSR. At present, this
function checks only for PRIMARY Hotkeys and does not compare the
'shift state' required for activation, assuming that a TSR that
uses ATL-T to pop up would conflict with a TSR that uses Shift-Alt-
T.
Parameters:
HotKey...................Scan Code of key to use for Hotkey
Returns:
FFFFh -- Hotkey conflicts with TSR already loaded
Anything else signifies it is safe to install a TSR with this hotkey.
C Language Usage:
extern unsigned far pascal TsCheckHotkey(
unsigned char HotKey
);
Pascal Usage:
function TsCheckHotkey(
HotKey : word
) : word;
Assembler Usage:
mov ax,5453h
mov bx,02h
mov cl,HotKey
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 38 TesSeRact(TM) Documentation (Ver. 1.00)
Replace Default Interrupt 24h Handler (Function 03h)
This function is used to replace the TesSeRact default Critical Error
Handler routine. The default procedure returns a FAIL code to the
calling program. This routine allows the developer to replace that
function with his own. Registers on entry to this routine are the
same as described in the DOS Technical Reference Manual, and all
conditions described there are in effect. Once control has been
passed to this routine, it is the developer's responsibility to
return back to DOS or the calling program. Please note that this
routine, if implemented by the developer, cannot be called until
the TSR has been enabled by TsDoInit(); this should be called
during the initialization phase of TsrCleanup().
Parameters:
TsrIdNum.................Identification Number of TSR to call
UserCritErrProc..........Pointer to Function to call
Returns:
Non-Zero -- Unable to install handler -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned far pascal TsSetUser24(
unsigned short TsrIdNum,
void (far *UserCritErrProc) (void)
);
Pascal Usage:
function TsSetUser24(
TsrIdNum : word;
UserCritErrProc : pointer
) : integer;
Assembler Usage:
mov ax,5453h
mov bx,03h
lds si,UserCritErrProc
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 39
Return TesSeRact Data Pointer (Function 04h)
This function returns a pointer to the specified TSR's internal data
areas. This block contains internal information about the TSR.
The structure is described in detail in Chapter 4 as the TsrData
structure. Note that other TesSeRact Multiplex Functions provide
information that is also available from the data contained in this
structure; they are designed to be used as an alternative method
for getting information about the TSR.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
NULL = No Matching TSR ID Number found
Otherwise, FAR pointer to TsrData structure
C Language Usage:
extern struct TsrData far * far pascal TsGetData(
unsigned short TsrIdNum
);
Pascal Usage:
function TsGetData(
TsrIdNum : word
) : DataPtr
Assembler Usage:
mov ax,5453h
mov bx,04h
mov cx,TsrIdNum
int 2fh
or ax,ax
jnz not_found
;
; Pointer returned in ES:BX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 40 TesSeRact(TM) Documentation (Ver. 1.00)
Set Multiple Hot Keys (Function 05h)
This function is used to set multiple hotkeys for a TSR. The
TsDoInit() function only has facilities for a single HotKey/Shift-
State combination, which should suffice for the majority of
resident programs. However, many programmers want the ability to
set up multiple hotkeys. Please note that this routine, if
implemented by the developer, cannot be called until the TSR has
been enabled by TsDoInit(); this should be called during the
initialization phase of TsrCleanup().
Parameters:
TsrIdNum.................Identification Number of TSR to call
count....................Number of Extra Keys to install
ExtraHotKeys.............Pointer to an array of struct ExtraHots
Returns:
Non-Zero -- Unable to install hotkeys -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned far pascal TsSetExtraHot(
unsigned short TsrIdNum,
unsigned char count,
struct ExtraHot far *ExtraHotKeys
);
Pascal Usage:
function TsSetExtraHot(
TsrIdNum : word;
Count : byte;
ExtraKeys : pointer
) : word;
Assembler Usage:
mov ax,5453h
mov bx,05h
mov cx,TsrIdNum
mov dl,count
lds si,ExtraHotKeys
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 41
TSR Manipulation and Status Routines
The TesSeRact Multiplex Functions in this group are designed to be called
by both resident and non-resident portions of applications. Appropriate
use of these functions, many of which can be directly applied to the
TesSeRact Data Areas, makes communication and manipulation of TesSeRact
programs simple.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 42 TesSeRact(TM) Documentation (Ver. 1.00)
Enable TSR (Function 10h)
This function calls the TesSeRact Multiplex interrupt to turn on the
'enable' flag for a TSR. It is the functional opposite of the
TsDisable() function.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
Non-Zero -- Unable to enable TSR -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned pascal TsEnable(
unsigned short TsrIdNum
);
Pascal Usage:
procedure TsEnable(
TsrIdNum : word
);
Assembler Usage:
mov ax,5453h
mov bx,10h
mov cx,TsrIdNum
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 43
Disable TSR (Function 11h)
This function turns off the 'enable' flag for a TSR. The TSR remains
in memory, but it cannot pop up, nor will any of its other
operations be active. As soon as it is enabled again, actions on
'hold' (like keys stuffed into the buffer) will immediately take
place. It is the functional opposite of the TsEnable() function.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
Non-Zero -- Unable to disable TSR -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned pascal TsDisable(
unsigned short TsrIdNum
);
Pascal Usage:
procedure TsDisable(
TsrIdNum : word
);
Assembler Usage:
mov ax,5453h
mov bx,11h
mov cx,TsrIdNum
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 44 TesSeRact(TM) Documentation (Ver. 1.00)
Release TSR [unload] (Function 12h)
This function allows for releasing a TSR from memory at the earliest
possible moment. In order for a TSR to remove itself, it must be
the last interrupt in the interrupt chain for *every* interrupt it
uses. If another program is loaded that interferes with the
interrupt chain, the TesSeRact Library will wait until it is safe
to remove your TSR from RAM.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
Non-Zero -- Unable to release TSR -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned pascal TsRelease(
unsigned short TsrIdNum
);
Pascal Usage:
procedure TsRelease(
TsrIdNum : word
);
Assembler Usage:
mov ax,5453h
mov bx,12h
mov cx,TsrIdNum
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 45
Restart TSR (Function 13h)
This function is used to 'restart' a TSR that has been released but is
still physically in memory. Note that TsrCleanUp() is NOT called
again for initialization, because the program has never been
notified through the same routine that it was removed.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
Non-Zero -- Unable to restart TSR -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned pascal TsRestart(
unsigned short TsrIdNum
);
Pascal Usage:
procedure TsRestart(
TsrIdNum : word
);
Assembler Usage:
mov ax,5453h
mov bx,13h
mov cx,TsrIdNum
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 46 TesSeRact(TM) Documentation (Ver. 1.00)
Get TSR Status Word (Function 14h)
This function is used to determine what the current status flags are
for the specified TSR. The possible values are the same as for the
TsrFlags parameter to TsDoInit(). Note also that this status word
may also be accessed directly by modifying the TsrStatus word from
the TsrParms Data Structure. The high-level language functions
specifically return the status flags if no error occurred; the
assembler version is atypical in that this value is not returned in
AX, as expected.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
FFFFh - invalid TSR ID Code
Any other value is current status flags
C Language Usage:
extern unsigned far pascal TsGetStat(
unsigned short TsrIdNum
);
Pascal Usage:
function TsGetStat(
TsrIdNum : word
) : word;
Assembler Usage:
mov ax,5453h
mov bx,14h
mov cx,TsrIdNum
int 2fh
or ax,ax
jnz invalid_idnum
;
; result returned in BX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 47
Set TSR Status Word (Function 15h)
This function is used to modify the existing status flags for the
specified TSR. The possible values are the same as for the
TsrFlags parameter to TsDoInit(). Please note that the NewStatus
parameter will OVERRIDE the existing status flags; it is
recommended that the user call TsGetStat() prior to this call and
only make the necessary changes to the status word.
Parameters:
TsrIdNum.................Identification Number of TSR to call
NewStatus................New status WORD for specified TSR
Returns:
Non-Zero -- Unable to set status word -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned far pascal TsSetStat(
unsigned short TsrIdNum,
unsigned short NewStatus
);
Pascal Usage:
function TsSetStat(
TsrIdNum : word
NewStatus : word
) : word;
Assembler Usage:
mov ax,5453h
mov bx,15h
mov cx,TsrIdNum
mov dx,NewStatus
int 2fh
;
; return code returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 48 TesSeRact(TM) Documentation (Ver. 1.00)
Get Indos State at Popup (Function 16h)
This function is used to determine what the state of DOS was at the
time of the popup. Under some conditions, certain things cannot be
done while INDOS is 1 (like SHELLing to a new copy of COMMAND.COM)
but are perfectly valid when INDOS is 0. The value returned by
this routine is only valid when called during TsrMain(),
TsrBackCheck(), or TsrBackProc() procedures. Also note that the
value returned here is the same as the PopupType member of the
TsrData structure.
Parameters:
TsrIdNum.................Identification Number of TSR to call
Returns:
FFFFh - invalid TSR ID Code
Any other value is current status flags
C Language Usage:
extern unsigned far pascal TsGetPopType(
unsigned short TsrIdNum
);
Pascal Usage:
function TsGetPopType(
TsrIdNum : word
) : word;
Assembler Usage:
mov ax,5453h
mov bx,16h
mov cx,TsrIdNum
int 2fh
or ax,ax
jnz invalid_idnum
;
; result returned in BX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 49
TSR Utility Routines
This group of TesSeRact Multiplex Functions was designed specifically for
communication and action of resident programs. With this release of
TesSeRact, there are only two functions in this category -- Call User
Procedure and Stuff Keyboard.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 50 TesSeRact(TM) Documentation (Ver. 1.00)
Call User Procedure (Function 20h)
This function is designed to allow an external application (or a
second invocation of the application) to call into the primary TSR.
This should generally be used to change status, such as turning a
feature on or off, adding files to a print queue, etc. The UserPtr
parameter is passed to the TsrUserProc() function of the specified
TSR. No specifications or recommendations are made as to what this
pointer should reference.
Parameters:
TsrIdNum.................Identification Number of TSR to call
UserPtr..................User-defined, FAR pointer to ANYTHING
Returns:
Non-Zero -- Unable to pass pointer -- invalid ID Number
Zero -- Success
C Language Usage:
extern unsigned far pascal TsCallUserProc(
unsigned short TsrIdNum,
void far *UserPtr
);
Pascal Usage:
function TsCallUserProc(
TsrIdNum : word;
UserPtr : pointer
) : word;
Assembler Usage:
mov ax,5453h
mov bx,20h
mov cx,TsrIdNum
les di,UserPtr
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 51
Stuff Keyboard (Function 21h)
This function allows an application to 'stuff' keystrokes into the
BIOS keyboard buffer. If the high byte of the 'Speed' parameter is
zero, both ASCII code and SCAN code must be provided in the buffer
passed to this function. The correct sequence is 'ASCII code'
followed by 'scan code.' If the high byte of the Speed parameter
is NON-ZERO, then only the ASCII code is needed -- the TesSeRact
routines will automatically place a '0' in the buffer for the scan
code (except for a <RETURN> -- for which the routines place the
correct scan code of '1Ch' in the buffer). If there is not enough
room in the internal 80-character (160-byte) buffer for the entire
buffer being passed, NONE of the characters are stuffed. If this
function returns the value 'F0F0 (hex),' it signifies that the user
pressed Control-C or Control-Break and should do any processing
necessary to abort a keyboard stuff. Note that the buffer that
KbdPtr references is an array of characters; if stuffing scan codes
and ASCII codes, make sure you reference the two bytes correctly.
Also, KbdLen is NOT the number of bytes in the array; it is the
number of characters to stuff!
Parameters:
TsrIdNum.................Identification Number of TSR to call
KbdPtr...................Pointer to buffer to stuff
KbdLen...................Number of characters to place in buffer
Speed....................0=Slow (only stuff when buffer is empty)
1=Medium (four characters per tick)
2=Fast (up to 15 characters per tick)
If high byte is non-zero, KbdPtr is an
array of ASCII codes; if it is zero,
KbdPtr is an array of ASCII/Scan Code
pairs.
Returns:
F0F0h -- User aborted paste with ^C or ^Break
Non-Zero -- Unable to stuff buffer -- invalid ID Number or buffer full
Zero -- Success
C Language Usage:
extern unsigned far pascal TsStuffKeyboard(
unsigned short TsrIdNum,
void far *KbdChars,
unsigned short CharCount,
unsigned short Speed
);
(continued)
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 52 TesSeRact(TM) Documentation (Ver. 1.00)
Pascal Usage:
function TsStuffKeyboard(
TsrIdNum : word;
KbdPtr : pointer;
KbdLen : word;
Speed : word
) : word;
Assembler Usage:
mov ax,5453h
mov bx,21h
mov cx,TsrIdNum
les di,KbdPtr
mov si,KbdLen
mov dx,Speed
int 2fh
;
; result returned in AX
;
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 53
Chapter 8. Writing a TesSeRact TSR -- A Tutorial
This chapter is intended to briefly describe the steps needed to create a
TesSeRact TSR. Language-specific differences are covered in Chapter 9 --
this chapter serves only as an outline to the general procedure.
The first step is to design your program. Write it, test it, debug it --
all without ever considering a TSR. Put your main procedural statements
OUTSIDE of the primary execution loop [main() for C programmers] -- in a
separate function, for example.
Once you've got the application debugged, the next step is to set up your
stack areas. The stack should be split into two parts, for both background
and popup processing. If you only use one type of processing in your TSR,
you should specify a small (4 bytes, or so) area for the other stack.
Also, if you are using a high-level language, it is strongly recommended
that you use a stack that is within the default stack area provided by your
compiler -- because many functions assume certain things about the stack.
Now determine what kind of TSR processing you need -- background, popup,
timer, or a combination of the three. Also determine if you need to be
able to communicate with the resident portion of the program, with a user-
procedure.
Define the TesSeRact entry points: TsrBackCheck(), TsrBackProc(),
TsrTimerProc(), TsrMain(), TsrUserProc() and TsrCleanUp(). Note that users
of the assembler version must define ALL these entry points in their code
in order to resolve linker references. High-level language users will find
dummy procedures provided to handle these references.
Your primary loops of execution should be placed in either TsrMain() or
TsrBackProc(). Small bits of code to test flags or other status should be
placed in TsrBackCheck() and TsrTimerProc() -- and remember that
TsrBackCheck() returns a flag that determines if TsrBackProc() is to be
called.
Now it's time to set up your data structures. Variables for hotkey and
shift state values should be set up so that they can be easily changed. An
eight-byte array of characters should be defined, which will become your
TSR Identification String. USE EIGHT CHARACTERS! Pad the string to eight
bytes if needed, because the TesSeRact routines check all eight bytes for a
match. Also define a data area that will be used to store your
Identification Number.
If you plan to use multiple hot keys, set up an ExtraHot structure that
contains the scan code, shift state and flag byte for each additional
hotkey you want.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 54 TesSeRact(TM) Documentation (Ver. 1.00)
Next it's time to begin adding the TesSeRact code to your program. As
early in execution as possible, set up pointers to your internal stack
areas, and call TsSetStack(). Next, call TsCheckResident(), passing
pointers to your Identification String and Identification Number. This
routine will pace the appropriate identification number in the data area
you indicate. This identification number will be used on all future calls
to TesSeRact once you call TsDoInit().
This is a good place to call TsCheckHotkey() to make sure that another TSR
is not already using the hotkey combination you want.
Finally, a call is made to TsDoInit(), passing it the appropriate
parameters as described in the documentation. The most important parameter
to this function is the resident size. Calculating this correctly will
solve many problems!
If you're using multiple hotkeys, or need to communicate through the
TesSeRact Multiplex interface, the time to do it is inside the
initialization portion of TsrCleanUp(). This function is called AFTER the
TesSeRact interrupts have been installed. In my TSRs, I generally do all
my initialization (except for memory allocation) inside this routine.
Please note that it is not possible to call a TesSeRact Multiplex Function
before TsrCleanUp() is called. The Multiplex routines are dependent on the
interrupt handler being installed.
And that's all there is to it! Of course, there are many other things you
can do -- for example, if when you call TsCheckResident(), you determine
that your program is already resident, you can do a variety of things --
pass new parameters to the resident portion using TsrUserProc(), etc. You
can modify the hotkeys, status, or anything as needed.
For more specific examples of this, see Chapter 9 for language-specific
details, and also see the demonstration programs.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 55
Chapter 9. Language Specifics
This chapter is designed to explain how to compile/assemble/link your Ram-
Resident programs with the appropriate version of TesSeRact. It also will
describe any language-specific variables or procedures that must be called.
A close study of the demonstration code would be useful while reading this
chapter.
Turbo C
Writing a TSR with Turbo C is very straightforward. Remembering that the
stack is ABOVE the heap in tiny and small models, developers can use a
routine such as the SizeOfCode() module provided in the demonstration
program. This routine allows developers to determine how much of the heap
and stack the developer wants to be resident. If you specify ALLSTACK, it
is absolutely possible to use Turbo-C's normal dynamic memory allocation
routines (malloc, free, etc.) in tiny or small model (farmalloc() and
dynamic memory under other memory models is a different subject entirely).
Developers should set the size of the heap and stack they desire by setting
_heaplen and _stklen to appropriate values.
The Turbo C demonstration program was compiled with the following command
line:
TCC -C -M -w -K -O -Z -k -d TESSDEMO
tlink /m /l /s /c c0s+tessdemo,tessdemo,tessdemo,tess+cs
One other item of consideration for TC is the need to call the
_restorezero() function from the termination portion of TsrCleanUp(). This
is needed to restore the Interrupt 0 vector to its former position. Other
packages or library routines may install their own termination handlers;
please note that at present, TC 1.5 does not provide a mechanism for easily
detecting their presence, other than by actually searching and modifying
the _atexit() chain.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 56 TesSeRact(TM) Documentation (Ver. 1.00)
Microsoft C
From a functional standpoint, the only difference between using Microsoft C
for a TSR as opposed to Turbo C is that instead of calling _restorezero(),
you instead call _ctermsub(). Note that this function DOES call all
procedures in the _atexit() chain, safely unlinking anyone who needs to be
unlinked. Also, since the stack is BELOW the heap in MSC small and medium
models, using dynamic memory allocation functions is a chancy thing, since
the RUN-TIME LIBRARY code has no way of knowing that you've put an
arbitrary limit on the size of the heap.
TESSDEMO may be compiled with MSC using the following command lines:
CL /W3 /Ox /DMSC5 TESSDEMO.C
By defining the variable MSC5, routines are compiled that are provided with
the Turbo C RUNTIME LIBRARY, allowing the program to run.
Some problems have been noted concerning the console I/O functions of
Microsoft C version 5.0 and 5.1. We are currently unclear as to what
exactly the problems are, but we recommend you do not use cputs() and
cprintf() from inside your TSR. Note that the problem is not due to a DOS
reentrancy problem -- because making the DOS function calls directly works
just fine.
Another thing to be aware of is that many MSC functions call malloc()
without being documented to do so -- printf() is one in particular. Be
careful about your heap management with MSC.
Finally, note that the size of the stack under MSC may be controlled either
by using the EXEMOD program and directly modifying the EXE header
information, or by using the /STACK parameter at the link step.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 57
Turbo Pascal
To use TesSeRact with Turbo Pascal 4.0, you need simply add the line:
Uses TESSTP;
to your program. The various function, procedure and CONST declarations
are located in the TESS.TP4 file.
Please note that when using TP4, there is one additional procedure that
MUST be called before ANY of the other TesSeRact routines. Because of the
organization of TP4 units, it is not possible to have code in the unit
directly call routines in the main section of the code. To get around
this, the TP Unit has been written with indirect calls to these locations,
which are initialized to FAR RETURNS. In order to set the appropriate
addresses into these data locations, TP4 users must call the TsSetAdrTP4
procedure, described below:
procedure TsSetAdrTP4(
ProcAdr : pointer;
Index : integer
);
This procedure exists only in the TP4 version; it is used to set the
TesSeRact pointers to permit popup of your own routines. During
initialization of the unit, all six pointers are set to a FAR RET
within the unit; your code must reset those you want to use, via
"TsSetAdrTP4( @TsrMain, 2 );" etc. The index codes to use are:
0 = TsrTimerProc
1 = TsrBackProc
2 = TsrMain
3 = TsrBackCheck
4 = TsrUserProc
5 = TsrCleanUp
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 58 TesSeRact(TM) Documentation (Ver. 1.00)
Assembler
Writing a TesSeRact program using the assembler version affords the
programmer the most compact code (because NEAR calls are used, rather than
FAR), as well as the most flexibility. The TesSeRact routines in this
version ASSUME that CS=DS, and any function that references the DI register
also assumes that ES=CS. This version will ONLY work for .COM-style
programs. It is not, however, necessary for the developer to use the
following common code sequence:
ORG 100h
start:
jmp begin
.....
END START
because the TesSeRact library already has the code embedded within it. The
program must have a PUBLIC variable called TESSINITSTART. The TesSeRact
Library gets control of the program and does a NEAR JMP to that label. All
registers that are normally in effect at the beginning of a .COM program
are still as they were.
Other than this label, there are some minor differences in calling some of
the TesSeRact Library Routines; most notably, TsDoInit() takes the OFFSET
of the top of memory, as is the common practice for .COM programs, as
opposed to the number of paragraphs of RAM required. The TsDoInit() module
will convert to paragraphs.
Please note also that ALL the entry points MUST exist in the code. See the
example program for more details.
The TESSPARK demonstration program was assembled/linked using SLR Systems
OPTASM 1.0, and Borland International's TLINK 1.1 as noted below.
Microsoft's MASM and LINK utilities work just as well.
OPTASM /Mx tesspark;
TLINK /M /L /S /C tess_asm+tess_bp+tesspark+tess_end,tesspark;
The functions located in TESS_END.OBJ are not used after the TSR is
initialized and should therefore be placed in the .EXE file past the end of
the resident portion of your program. TESS_BP.OBJ has been provided as a
separate module to allow ease in replacing it with your own BEEP routine.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 59
Chapter 10. Communicating with the TesSeRact
NOTE: This chapter, with the following copyright notice and attribution,
may be included with any/all products using the TesSeRact Library or
supporting the TesSeRact Standard for Ram-Resident Program Communication.
Copyright 1988, TesSeRact Development Team
All Rights Reserved
By Chip Rabinowitz and Jim Kyle
In order for a program to communicate with routines which use the TesSeRact
Standard, it MUST make use of the TesSeRact Multiplex Functions.
The TesSeRact Standard for Ram-Resident Program Communication is a group of
functions, latched onto DOS' own Interrupt 2Fh (Multiplex). DOS uses this
interrupt to communicate with its own TSRs (PRINT.COM, ASSIGN.COM,
SHARE.COM), and the TesSeRact Development Team felt it was appropriate to
service TSR programs using the same interface. These functions are all
accessed by generating an Interrupt 2Fh, with AX=5453 (hex).
Important! In versions of MS-DOS and PC-DOS prior to 3.0, the Interrupt
2Fh vector was initialized to zero rather than being pointed into the DOS
service area. With such DOS versions, a program calling Interrupt 2Fh will
cause the machine to crash if a TesSeRact TSR has not been loaded.
TsVerify2F() should be called prior to calling this function, or the
application should make its own check for the validity of Interrupt 2Fh.
To determine whether any routine is, in fact, using the TesSeRact Standard,
use Multiplex Function 00h (Check Install). Check Install determines
whether a TesSeRact program has been loaded. It is called in the following
fashion (the assembler interface is required if the TesSeRact Library is
not available. If it is, refer to the section on the Multiplex functions
for details of its use in high level languages):
mov ax,5453h ;the TesSeRact Multiplex signature
mov si,offset IDStr ;FAR pointer to 8-character name of
mov ds,seg IDStr ; routine being checked for
xor cx,cx ;will count TesSeRact using CX
xor bx,bx ;specify Function 00h
int 2fh
IDStr is an eight-byte data area that contains the TSR Identification
String unique to the particular TSR program. All eight bytes are
significant when comparing strings, so make sure you specify the values for
ALL eight bytes. If necessary, pad an IDStr array with spaces to ensure
eight unique bytes.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 60 TesSeRact(TM) Documentation (Ver. 1.00)
If no TesSeRact routine is present in the system, the interrupt will return
with the signature in the AX register unchanged. If the routine being
sought is present, AX will contain 0FFFFh, and the CX register will contain
its Identification Number. This ID Number is used by all the remaining
TesSeRact Multiplex Functions, rather than the full Identification String,
and should be saved for use.
Note that Check Install will ALWAYS return an Identification Number for the
routine being sought if ANY TesSeRact TSR is present, even though the
routine may not yet be present in the system. The second step in making
certain that the routine is, in fact, present is to request a pointer to
its data area.
Check Install does no initialization of internal data structures, and
should ONLY be used by a program to FIND a TSR in memory and get it's
handle -- NOT to determine if a TSR has already been loaded.
In the TesSeRact Standard, Multiplex Function 01h returns a FAR pointer to
a data area that contains the TsrParms pointer -- including the
Identification String, Identification Number, and FuncFlag members for the
TSR bearing the IdNum passed into the function. This function is called as
follows:
mov ax,5453h
mov bx,01h
mov cx,TsrIdNum
int 2fh
If the Identification Number in CX matches the TSR's ID Number (which was
returned by Multiplex Function 00h), the TSR returns with ES:BX pointing to
the TsrParms area and AX equal to zero. Any other value in AX upon return
indicates that the TSR could not be located.
Once the pointer to the User Parameter Area is obtained, most of the
critical information used by the routine is available to the calling
program.
Other TesSeRact Multiplex Functions may be accessed by calling the
appropriate Interrupt 2Fh Multiplex function call, as described below.
Please note that these are narrative descriptions of the Multiplex
functions only -- complete descriptions are available in the TesSeRact
Documentation.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 61
Check Install (Function 00h)
This function must be called before TsDoInit(). It checks to see if
this TSR has already been loaded by comparing the passed IDStr with
other compatible TSRs. The primary difference between Check
Install and TsCheckResident() is that Check Install does no
initialization of internal data structures, and should ONLY be used
by a program to FIND a TSR in memory and get its handle -- NOT to
determine if the TSR you are trying to install has already been
loaded. Please note that under DOS versions 2.x, the Interrupt 2Fh
vector is initialized to ZERO -- a program calling Interrupt 2Fh
will cause the machine to crash if a TesSeRact TSR has not been
loaded. TsVerify2F() should be called prior to calling this
function, or the application should make its own check for the
validity of Interrupt 2Fh.
Return User Parameter Pointer (Function 01h)
This function returns a pointer to the specified TSR's parameter
block. This block contains important information about the TSR.
The structure is described in detail in Chapter 4 of the TesSeRact
Documentation as the TsrParms structure. Note that other TesSeRact
Multiplex Functions provide information that is also available from
the data contained in this structure; they are designed to be used
as an alternative method for getting information about the TSR.
Check Hotkey (Function 02h)
This function is used to determine if the selected hotkey is not in
use by any other TesSeRact-compatible TSR. At present, this
function checks only for PRIMARY Hotkeys and does not compare the
'shift state' required for activation, assuming that a TSR that
uses ATL-T to pop up would conflict with a TSR that uses Shift-Alt-
T.
Replace Default Interrupt 24h Handler (Function 03h)
This function is used to replace the TesSeRact default Critical Error
Handler routine. The default procedure returns a FAIL code to the
calling program. This routine allows the developer to replace that
function with his own. Registers on entry to this routine are the
same as described in the DOS Technical Reference Manual, and all
conditions described there are in effect. Once control has been
passed to this routine, it is the developer's responsibility to
return back to DOS or the calling program. Please note that this
routine, if implemented by the developer, cannot be called until
the TSR has been enabled by TsDoInit(); this should be called
during the initialization phase of TsrCleanup().
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 62 TesSeRact(TM) Documentation (Ver. 1.00)
Return TesSeRact Data Pointer (Function 04h)
This function returns a pointer to the specified TSR's internal data
areas. This block contains internal information about the TSR.
The structure is described in detail in Chapter 4 as the TsrData
structure. Note that other TesSeRact Multiplex Functions provide
information that is also available from the data contained in this
structure; they are designed to be used as an alternative method
for getting information about the TSR.
Set Multiple Hot Keys (Function 05h)
This function is used to set multiple hotkeys for a TSR. The
TsDoInit() function only has facilities for a single HotKey/Shift-
State combination, which should suffice for the majority of
resident programs. However, many programmers want the ability to
set up multiple hotkeys. Please note that this routine, if
implemented by the developer, cannot be called until the TSR has
been enabled by TsDoInit(); this should be called during the
initialization phase of TsrCleanup().
Enable TSR (Function 10h)
This function calls the TesSeRact Multiplex interrupt to turn on the
'enable' flag for a TSR. It is the functional opposite of the
TsDisable() function.
Disable TSR (Function 11h)
This function turns off the 'enable' flag for a TSR. The TSR remains
in memory, but it cannot pop up, nor will any of its other
operations be active. As soon as it is enabled again, actions on
'hold' (like keys stuffed into the buffer) will immediately take
place. It is the functional opposite of the TsEnable() function.
Release TSR [unload] (Function 12h)
This function allows for releasing a TSR from memory at the earliest
possible moment. In order for a TSR to remove itself, it must be
the last interrupt in the interrupt chain for every interrupt it
uses. If another program is loaded that interferes with the
interrupt chain, the TesSeRact Library will wait until it is safe
to remove your TSR from RAM.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 63
Restart TSR (Function 13h)
This function is used to 'restart' a TSR that has been released but is
still physically in memory. Note that TsrCleanUp() is NOT called
again for initialization, because the program has never been
notified through the same routine that it was removed.
Get TSR Status Word (Function 14h)
This function is used to determine what the current status flags are
for the specified TSR. The possible values are the same as for the
TsrFlags parameter to TsDoInit(). Note also that this status word
may also be accessed directly by modifying the TsrStatus word from
the TsrParms Data Structure. The high-level language functions
specifically return the status flags if no error occurred; the
assembler version is atypical in that this value is not returned in
AX, as expected.
Set TSR Status Word (Function 15h)
This function is used to modify the existing status flags for the
specified TSR. The possible values are the same as for the
TsrFlags parameter to TsDoInit(). Please note that the NewStatus
parameter will OVERRIDE the existing status flags; it is
recommended that the user call TsGetStat() prior to this call and
only make the necessary changes to the status word.
Get Indos State at Popup (Function 16h)
This function is used to determine what the state of DOS was at the
time of the popup. Under some conditions, certain things cannot be
done while INDOS is 1 (like SHELLing to a new copy of COMMAND.COM)
but are perfectly valid when INDOS is 0. The value returned by
this routine is only valid when called during TsrMain(),
TsrBackCheck(), or TsrBackProc() procedures. Also note that the
value returned here is the same as the PopupType member of the
TsrData structure.
Stuff Keyboard (Function 21h)
This function is designed to allow an external application (or a
second invocation of the application) to call into the primary TSR.
This should generally be used to change status, such as turning a
feature on or off, adding files to a print queue, etc. The UserPtr
parameter is passed to the TsrUserProc() function of the specified
TSR. No specifications or recommendations are made as to what this
pointer should reference.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 64 TesSeRact(TM) Documentation (Ver. 1.00)
Call User Procedure (Function 20h)
This function allows an application to 'stuff' keystrokes into the
BIOS keyboard buffer. If the high byte of the 'Speed' parameter is
zero, both ASCII code and SCAN code must be provided in the buffer
passed to this function. The correct sequence is 'ASCII code'
followed by 'scan code.' If the high byte of the Speed parameter
is NON-ZERO, then only the ASCII code is needed -- the TesSeRact
routines will automatically place a '0' in the buffer for the scan
code (except for a <RETURN> -- for which the routines place the
correct scan code of '1Ch' in the buffer). If there is not enough
room in the internal 80-character (160-byte) buffer for the entire
buffer being passed, NONE of the characters are stuffed. If this
function returns the value 'F0F0 (hex),' it signifies that the user
pressed Control-C or Control-Break and should do any processing
necessary to abort a keyboard stuff. Note that the buffer that
KbdPtr references is an array of characters; if stuffing scan codes
and ASCII codes, make sure you reference the two bytes correctly.
Also, KbdLen is NOT the number of bytes in the array; it is the
number of characters to stuff!
Any developer wishing a copy of the source code for TesSeRact's Interrupt
2Fh Multiplex Handler may receive it by sending a self-addressed, stamped
envelope to:
TesSeRact Development Team
c/o Chip Rabinowitz
2084 Woodlawn Avenue
Glenside, PA 19038
For more information contact the TesSeRact Development Team at the above
address, or at Compuserve 70731,20, or MCIMAIL 315-5415 (TESSERACT).
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 65
Chapter 11. Writing TesSeRact-Compatible Programs
NOTE: This chapter, with the following copyright notice and attribution,
may be included with any/all products using the TesSeRact Library or
supporting the TesSeRact Standard for Ram-Resident Program Communication.
Copyright 1988, TesSeRact Development Team
All Rights Reserved
By Chip Rabinowitz and Jim Kyle
The TesSeRact Development Team was organized in early 1986 for the sole
purpose of establishing a standard to be shared by TSR program developers
in the hopes of reducing the notorious levels of conflicts between such
programs. The members of the Development Team represented a majority of
the leading independent TSR developers.
At first, the Team planned on developing a full Applications Program
Interface for use by both independent and commercial programs.
Unfortunately, the team was unable to get strong enough support from the
commercial TSR publishing houses and this idea went by the wayside.
The current TesSeRact product consists of both a Library of routines that
enable developers to write safe Ram-Resident programs, and an interface
that permits developers to communicate with their own (and other) TSRs.
The TesSeRact Standard for Ram-Resident Program Communication is a group of
functions, latched onto DOS' own Interrupt 2Fh (Multiplex). DOS uses this
interrupt to communicate with its own TSRs (PRINT.COM, ASSIGN.COM,
SHARE.COM), and the TesSeRact Development Team felt it was appropriate to
service TSR programs using the same interface. These functions are all
accessed by generating an Interrupt 2Fh, with AX=5453 (hex).
In order for a program to support the TesSeRact Standard, it MUST provide
the following Multiplex Functions:
Function 00h (Check Install)
Function 01h (Return User Parameter Pointer)
Check Install is used by TesSeRact programs to determine if the program has
been loaded before. It is called in the following fashion:
mov ax,5453h
mov si,offset IDStr
mov ds,seg IDStr
xor cx,cx
xor bx,bx
int 2fh
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 66 TesSeRact(TM) Documentation (Ver. 1.00)
IDStr is an eight-byte data area that contains a unique TSR Identification
String. The Interrupt 2F routine should compare the passed string (as
shown in the example below), with its own eight-byte string. If the two
strings match, the TSR should return with the CX register set to its own
TSR 'handle' and the AX register set to 0FFFFh.
If the identification strings do not match, all the registers should be
restored, then the CX registers should be INCREMENTED, and the interrupt
handler should call down the chain.
Why is it done this way, you may ask? If every TesSeRact-compatible TSR on
a particular system increments the CX register if there is no match, then
when the interrupt procedure returns to the caller, the CX register will
contain the next available handle!
The following code is taken directly from the TesSeRact Library's Interrupt
2Fh handler:
finish_2f:
add sp,4 ;get rid of two words on stack
xor ax,ax ;clear AX to show we got it
done_2f:
iret
next_one:
inc cx ;try next higher ID code
get_out_2f:
pop bx
pop ax
not_our_2f:
jmp DPTR [oldint2F]
overparms:
cmp ax,5453h ;ax=5453h for TesSeRact
jne not_our_2f
cmp bx,MAXENT
ja not_our_2f
push ax
push bx
or bx,bx ;do check for install first,
jz check_install ;so we can check ID number only
;one time!
.... ; other code .....
check_install:
;DS:SI points to ID string
;DI contains hotkey for check
;CX is current number in chain
; must be 0 from caller
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 67
push cx
push si ;save SI for next one
lea di,[USERPARMS]
push cs
pop es
mov cx,8
rep cmpsb
pop si
pop cx
jnz next_one ;no match, not us
pop bx
pop ax
mov cx,es:[di] ;return ID number in CX
test WPTR [STATUS],TSRRELEASED
jz return_idnum
or cx,0ff00h ;say we're released!
return_idnum:
xor ax,ax
dec ax ;AX=-1 means already here
jmp short done_2f
The other requirement for TesSeRact compatibility is to support the
TsrParms data area (Multiplex Function 01h). The UserParms area is
described as follows:
UserParms db 8 dup (0)
IdNum dw 0 ;TSR Identification Number
FuncFlag dd 0ffffffffh ;supported functions
HotKey db 0 ;Scan code of hotkey to use
ShiftSt db 0 ;shift state to use for popup
HotFlag db 0 ;Which hotkey is in use
ExtCnt db 0 ;number of extra hotkeys
ExtHot dd 0 ;pointer to extra hot keys
Status dw 0 ;TSR status flags
OurPSP dw 0 ;our PSP segment
OurDTA dd 0 ;our DTA region
DSeg dw 0 ;User's Default Data Segment
<<NOTE: This is only a partial listing of the full TsrParms
structure; see the complete TesSeRact documentation for more
details>>
For minimal support of the TesSeRact Standard, Multiplex Function 01h
should return a FAR pointer to a data area that contains the
Identification String, Identification Number, and FuncFlag members. This
function is called as follows:
mov ax,5453h
mov bx,01h
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 68 TesSeRact(TM) Documentation (Ver. 1.00)
mov cx,TsrIdNum
int 2fh
If the Identification Number in CX matches the TSR's ID Number (which was
returned by Multiplex Function 00h), the TSR should return with ES:BX
pointing to the TsrParms area and AX equal to zero.
The FuncFlag is a bit-mapped, four-byte variable that shows all Multiplex
functions that this TSR supports. This variable is mapped as follows:
Bit 0 Function 00h (check install -- REQUIRED)
Bit 1 Function 01h (return userparms -- REQUIRED)
Bit 2 Function 02h (check hotkey)
Bit 3 Function 03h (replace INT 24h)
Bit 4 Function 04h (return Data Pointer)
Bit 5 Function 05h (set extra hotkeys)
Bits 6-7 Undefined -- reserved for future use
Bit 8 Function 10h (enable TSR)
Bit 9 Function 11h (disable TSR)
Bit 10 Function 12h (release TSR from RAM)
Bit 11 Function 13h (restart TSR)
Bit 12 Function 14h (get current status)
Bit 13 Function 15h (set TSR status)
Bit 14 Function 16h (get popup type)
Bit 15 Undefined -- reserved for future use
Bit 16 Function 20h (Call user procedure)
Bit 17 Function 21h (stuff keyboard)
Bits 18-31 Undefined -- reserved for future use
If the TSR supports the particular function, the bit should be SET (1).
Otherwise, it should be zero. Note that a product using TesSeRact's
Library will return with FuncFlag set to (hex) FFFFFFFF. Other TSRs should
set the undefined variables to '0' to differentiate themselves.
The other TesSeRact Multiplex Functions are described in complete detail in
the full TesSeRact documentation. In addition, any developer wishing a
copy of the source code for TesSeRact's Interrupt 2Fh Multiplex Handler may
receive it by sending a self-addressed, stamped envelope to:
TesSeRact Development Team
c/o Chip Rabinowitz
2084 Woodlawn Avenue
Glenside, PA 19038
For more information contact the TesSeRact Development Team at the above
address, or at Compuserve 70731,20, or MCIMAIL 315-5415 (TESSERACT).
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 69
Appendix A. Quick Reference to TesSeRact Functions
External Functions
TsrMain -- Entry Point for Popup Routine
TsrBackCheck -- Check to see if background processing is requested
TsrBackProc -- Background Processing Procedure
TsrTimerProc -- Periodic Timer Procedure
TsrUserProc -- Interface for External Processing
TsrCleanUp -- Initialize or Clean Up TSR
TesSeRact Library Routines
TsDoInit -- Initializes variables and goes resident
TsSetStack -- Sets stacks to be used by resident routines
TsCheckResident -- Determine if program has been loaded
TsVerify2F -- Verify Interrupt 2Fh has valid handler
TessBeep -- Call TesSeRact Internal Beep Routine
TesSeRact Multiplex Functions
Initialization and Information Routines
Check Install
TsGetParms()
TsCheckHotkey()
TsSetUser24()
TsGetData()
TsSetExtraHot()
TSR Manipulation and Status Routines
TsEnable()
TsDisable()
TsRelease()
TsRestart()
TsGetStat()
TsSetStat()
TsGetPopType()
TSR Utility Routines
TsCallUserProc()
TsStuffKeyboard()
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 70 TesSeRact(TM) Documentation (Ver. 1.00)
Appendix B. Keyboard Scan Codes
Please note that these are not ALL the scan codes available, just the most
common ones you will be using for TSRs. Also, for Z-100 computers using
the ZPC Hardware Modifications, TSRPOPLSHIFT and TSRPOPRSHIFT are not
usable, since this machine does not distinguish between the two.
For those who are not familiar with the notation, '0x' denotes a
hexadecimal number.
TSRHOT_A equ 0x1E TSRHOT_B equ 0x30
TSRHOT_C equ 0x2E TSRHOT_D equ 0x20
TSRHOT_E equ 0x12 TSRHOT_F equ 0x21
TSRHOT_G equ 0x22 TSRHOT_H equ 0x23
TSRHOT_I equ 0x17 TSRHOT_J equ 0x24
TSRHOT_K equ 0x25 TSRHOT_L equ 0x26
TSRHOT_M equ 0x32 TSRHOT_N equ 0x31
TSRHOT_O equ 0x18 TSRHOT_P equ 0x19
TSRHOT_Q equ 0x10 TSRHOT_R equ 0x13
TSRHOT_S equ 0x1F TSRHOT_T equ 0x14
TSRHOT_U equ 0x16 TSRHOT_V equ 0x2F
TSRHOT_W equ 0x11 TSRHOT_X equ 0x2D
TSRHOT_Y equ 0x15 TSRHOT_Z equ 0x2C
TSRHOT_0 equ 0x0b TSRHOT_1 equ 0x02
TSRHOT_2 equ 0x03 TSRHOT_3 equ 0x04
TSRHOT_4 equ 0x05 TSRHOT_5 equ 0x06
TSRHOT_6 equ 0x07 TSRHOT_7 equ 0x08
TSRHOT_8 equ 0x09 TSRHOT_9 equ 0x0A
TSRHOT_F1 equ 0x3B TSRHOT_F2 equ 0x3C
TSRHOT_F3 equ 0x3D TSRHOT_F4 equ 0x3E
TSRHOT_F5 equ 0x3F TSRHOT_F6 equ 0x40
TSRHOT_F7 equ 0x41 TSRHOT_F8 equ 0x42
TSRHOT_F9 equ 0x43 TSRHOT_F10 equ 0x44
;
;Enhanced Keyboards only
;
;May not work with all computers, keyboards
;
TSRHOT_F11 equ 0x57 TSRHOT_F12 equ 0x58
;
;#defines for ShiftState
;
TSRPOPRSHIFT equ 0x01 TSRPOPLSHIFT equ 0x02
TSRPOPCTRL equ 0x04 TSRPOPALT equ 0x08
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 71
Appendix C. Reporting Bugs
Bugs found in the RELEASE version of TesSeRact should be reported
immediately to the TesSeRact Development Team at Compuserve 70731,20,
MCIMAIL 315-5415, or at 1-215-884-3373. The Development Team will make
every reasonable effort to repair said bug in the minimum amount of time.
Registered users who report verifiable bugs or who make enhancement
suggestions that are implemented in TesSeRact receive an automatic
registration to the next version of TesSeRact or a free source code
license.
When reporting bugs, please provide as MUCH information about your
configuration as possible; e.g., hardware manufacturer, BIOS manufacturer
and version number, DOS OEM info and version number, other Ram-Resident
software and device drivers, other hardware, etc. The more information
provided the Development Team, the better our response to your problems.
Technical Support for TesSeRact is provided free of charge in Subtopic 13
of the Computer Language Magazine Forum (GO CLMFOR) on CompuServe
Information Service.
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 72 TesSeRact(TM) Documentation (Ver. 1.00)
Glossary
This glossary is not intended to contain a complete description of all the
technical terms used in this document; it does, however, describe those
terms that relate to the topic of Ram-Resident programming. For details on
other terms, see other, more complete technical documentation about MS-DOS.
Assembly Language: A set of instructions, written in human-readable
form, that can be translated directly into the machine code used by
a computer. This is generally the lowest-level language used by
programmers.
Compiler: A computer program that converts the source code
instructions written in a high-level language (such as C or Pascal)
into either assembly language or machine code. Some compilers
produce an intermediate 'object' file, which contains additional
information not needed by the executable code, but used by other
programming utilities.
Data Structure: A set of information, grouped together in a logical,
pre-defined sequence.
Disk Transfer Address: This is a buffer used by some DOS functions to
transfer file data or information.
DOS: Disk Operating System. See also MS-DOS.
DTA (see Disk Transfer Address)
Graphics Mode: A type of video display mode that allows addressing of
individual graphic elements on the screen.
Hot Key: The keystroke or combination of keystrokes that can be used
to popup a Ram-Resident program
Memory Resident (See Terminate But Stay Resident)
Memory Size The amount of memory used by a Ram-Resident Program.
MS-DOS: Microsoft's Disk Operating System, originally designed for
the IBM-PC, now used by all IBM-compatible computers.
Multiplex Function: A TesSeRact Function that may be called by
external programs through the DOS Multiplex Interrupt (2Fh).
PC-DOS (See MS-DOS)
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 73
Program Segment Prefix: A 256-byte header that DOS puts in memory
immediately before all .EXE or .COM programs prior to executing the
program. It contains various information used by DOS to control
the executing of the program.
Popup: Used in two ways: 'To Popup' a program is to call the primary
routine (TsrMain()) used to run the Ram-Resident Program, generally
through the use of a Hotkey; also, 'A Popup' program is another
name for a Ram-Resident Program.
PSP (see Program Segment Prefix)
Ram-Resident (See Terminate But Stay Resident)
Shareware: A method of distributing software programs that allows
users the opportunity to 'test drive' a software program before
paying for it.
Stack An area in memory where the processor maintains addresses for
control information. It is also used by executing programs to
store temporary data.
Terminate But Stay Resident: A program that is kept in memory after
it terminates, in order to provide a useful function. The TSR may
be a Popup program, or it may be a background program, or it may be
a combination of the two.
Text Mode: A type of video display mode that automatically translates
video information into the appropriate graphic elements to display
characters.
TSR (See Terminate But Stay Resident)
Video Mode: An identification number that describes how the current
display information is being interpreted (i.e., text or graphics).
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
Page 74 TesSeRact(TM) Documentation (Ver. 1.00)
Index
_TESS_CPYRT....................16 Hercules Graphics Card.........11
_TESS_ENDOFDATA................16 Hot Key........................72
_TESS_ERROR24..................16 Hotkeyiv, 12, 15, 16, 17, 19, 21,
_TESS_INTERRUPTRETURN..........16 30, 37, 40, 54, 61, 62, 66, 67,
_TESS_TEMPPARMS................16 73
_TESS_VIDMODE..............11, 16 HOTKEYON.......................17
_TESS_VIDPAGE..............11, 16 IBMNET.........................10
_TESSDOPOPUP...................14 Identification Number.15, 28, 35,
_TESSRESTOREINTS...............12 36, 38, 39, 40, 42, 43, 44, 45,
_TESSSETUPINTS.................12 46, 47, 48, 50, 51, 53, 54, 60,
Assembler......12, 18, 33, 34, 58 67, 68
Assembly Language..............72 Identification String...2, 5, 15,
ASSIGN.COM.............iv, 59, 65 28, 35, 53, 54, 59, 60, 61, 66,
Association of Shareware 67
Professionals..............7, 8 INDOS......13, 14, 17, 30, 48, 63
Background.....................53 INT28ACTIVE....................17
BACKSET........................17 Interrupt 2Fh..iv, 3, 34, 59, 64,
BIOS...............iv, 19, 20, 71 65
Borland International........3, 4 Library...iv, vi, 1, 3, 4, 5, 12,
Bugs.....................v, 6, 71 15, 18, 19, 26, 32, 33, 34, 44,
reporting....................71 55, 58, 59, 62, 65, 68
Check Hotkey...................34 License.........................5
Check Install..............34, 59 General.......................1
CLMFOR......................6, 71 Registered User...............2
CLMFORUM.......................10 Source Code...................3
Compiler.......................72 Special....................4, 5
CompuServe..vii, 3, 4, 6, 10, 64, MCIMAIL.......3, 4, 6, 64, 68, 71
68, 71 Memory30, 35, 43, 44, 45, 58, 60,
Computer Language Magazine Forum 61, 62, 63
6, 71 allocation...............55, 56
Critical Error.................13 Expanded.....................10
Critical Error Flag........14, 30 Extended.....................10
Disk Transfer Address.13, 15, 19, Memory resident.............v, 72
21, 67, 72 Memory Size....................72
DOSiv, v, 13, 14, 16, 19, 20, 21, Microsoft..iv, v, 18, 26, 56, 58,
22, 24, 30, 32, 35, 38, 48, 59, 72
61, 63, 65, 71, 72, 73 Microsoft Word.................11
DOS Technical Reference Manual38, MS-DOS.....................59, 72
61 MS-DOS Encyclopedia.............v
ExtraHot...........12, 16, 40, 53 Multiplex..iv, vi, 3, 14, 15, 23,
EXTRAHOTSET....................17 24, 28, 34, 36, 39, 41, 42, 49,
EXTRAINT24.....................17 54, 59, 60, 61, 62, 64, 65, 68,
Freeware.....................1, 3 72
FuncFlag...............60, 67, 68 Newsletter......................5
FuncFlags......................15 NOPOPCOMMAND...................17
Graphics...............11, 14, 17 NOPOPGRAPH.................11, 17
Graphics Mode..................72 PC-DOS.....................59, 72
Hercules.......................11 POPFF..........................16
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved
TesSeRact(TM) Documentation (Ver. 1.00) Page 75
Index
Popup.11, 13, 14, 15, 17, 33, 48, TsrBackCheck..20, 21, 48, 53, 57,
53, 57, 63, 67, 68, 73 63
POPUPSET.......................17 TsrBackProc...20, 21, 23, 48, 53,
PRINT.COM..............iv, 59, 65 57, 63
Program Segment Prefix13, 15, 19, TsrCleanUp24, 34, 38, 40, 45, 53,
21, 23, 67, 73 54, 55, 57, 61, 62, 63
Ram-Resident...............iv, 73 TsrData....12, 13, 39, 48, 62, 63
RUN-TIME LIBRARY...............56 TsRelease......................44
SHARE.COM..............iv, 59, 65 TSRENABLED.....................17
Shareware.......1, 3, 5, 7, 8, 73 TsRestart..................28, 45
SHIFTSON.......................17 TsrFlags...17, 19, 30, 46, 47, 63
Source code.v, 1, 2, 3, 5, 6, 64, TsrIntTable................12, 13
68, 71, 72 TsrMain...14, 15, 16, 19, 21, 48,
Stack.13, 19, 20, 21, 22, 24, 26, 53, 57, 63, 73
53, 55, 56, 73 TsrParms..12, 15, 19, 36, 46, 60,
Background...........15, 23, 26 61, 63, 67, 68
Popup................15, 24, 26 TSRRELEASED....................17
Stack-checking.............19, 26 TsrStatus......15, 16, 17, 46, 63
Terminate But Stay Residentiv, 73 TsrTimerProc...........22, 53, 57
TESS-TP.TPU....................iv TSRUSEBACK.................17, 20
TESS.H.....................12, 17 TSRUSEPOPUP................17, 19
TESS.INC...................12, 17 TsrUserProc23, 50, 53, 54, 57, 63
TESS.LIB.......................iv TSRUSETIMER....................17
TESS.TP4...............12, 17, 57 TSRUSEUSER.....................17
TESS_BP.OBJ....................58 TsSetAdrTP4................18, 57
TESS_END.OBJ...................58 TsSetExtraHot.12, 16, 17, 19, 24,
TESS_GLOBALS...................13 40
TESS_USERPARMS.................15 TsSetStack.........19, 25, 26, 54
TessBeep...............11, 25, 33 TsSetStat......................47
TESSINITSTART..................58 TsSetUser24................14, 38
TESSPARK...................14, 58 TsStuffKeyboard................51
TESSTP.TPU.....................24 TsVerify2F.....25, 32, 35, 59, 61
Text Mode......................73 Tutorial.......................53
TIMERSET.......................17 USERPROCON.....................17
TsCallUserProc.................50 Video mode.............11, 16, 73
TsCheckHotkey..............37, 54 Warranty........................2
TsCheckResident...15, 25, 28, 32,
34, 35, 54, 61
TsDisable..............42, 43, 62
TsDoInit..11, 12, 15, 17, 24, 25,
28, 34, 35, 38, 40, 46, 47, 54,
58, 61, 62, 63
TsEnable...............42, 43, 62
TsGetData......................39
TsGetParms.....................36
TsGetPopType...................48
TsGetStat..............46, 47, 63
TSRACTIVE......................17
Copyright (c) 1988, TesSeRact Development Team, All Rights Reserved